package com.njcn.energy.service.impl;

import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njcn.energy.mapper.DataArrayMapper;
import com.njcn.energy.pojo.param.DataArrayParam;
import com.njcn.energy.pojo.po.DataArray;
import com.njcn.energy.service.IDataArrayService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 类的介绍：
 *
 * @author xuyang
 * @version 1.0.0
 * @createTime 2022/3/9 15:48
 */
@Service
public class DataArrayServiceImpl extends ServiceImpl<DataArrayMapper, DataArray> implements IDataArrayService {

    @Override
    public DataArray addDataArray(DataArrayParam dataArrayParam) {
        DataArray dataArray = new DataArray();
        BeanUtil.copyProperties(dataArrayParam,dataArray);
        this.save(dataArray);
        return dataArray;
    }

    @Override
    public boolean deleteDataArray(List<String> list) {
        QueryWrapper<DataArray> dataArrayQueryWrapper = new QueryWrapper<>();
        dataArrayQueryWrapper.in("Pid",list);
        return this.remove(dataArrayQueryWrapper);
    }
}
