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.DataGroupMapper;
import com.njcn.energy.pojo.param.DataGroupParam;
import com.njcn.energy.pojo.po.DataArray;
import com.njcn.energy.pojo.po.DataGroup;
import com.njcn.energy.pojo.po.DataSet;
import com.njcn.energy.service.IDataGroupService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 类的介绍：
 *
 * @author xuyang
 * @version 1.0.0
 * @createTime 2022/3/16 9:05
 */
@Service
public class DataGroupServiceImpl extends ServiceImpl<DataGroupMapper, DataGroup> implements IDataGroupService {
    @Override
    public DataGroup addDataGroup(DataGroupParam dataGroupParam) {
        DataGroup dataGroup = new DataGroup();
        BeanUtil.copyProperties(dataGroupParam,dataGroup);
        this.save(dataGroup);
        return dataGroup;
    }
    @Override
    public boolean batchAdd(List<DataGroup> list){
      return this.saveBatch(list);
    }
    @Override
    public List<DataGroup> findGroupById(List<String> list) {
        return this.lambdaQuery().in(DataGroup::getPid,list).list();
    }

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