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.DataSetMapper;
import com.njcn.energy.pojo.param.DataSetParam;
import com.njcn.energy.pojo.po.DataSet;
import com.njcn.energy.pojo.po.Hardware;
import com.njcn.energy.service.IDataSetService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 类的介绍：
 *
 * @author xuyang
 * @version 1.0.0
 * @createTime 2022/3/9 10:16
 */
@Service
public class DataSetServiceImpl extends ServiceImpl<DataSetMapper, DataSet> implements IDataSetService {

    @Override
    public DataSet add(DataSetParam dataSetParam) {
        DataSet dataSet = new DataSet();
        BeanUtil.copyProperties(dataSetParam,dataSet);
        this.save(dataSet);
        return dataSet;
    }

    @Override
    public boolean delete(String id) {
        QueryWrapper<DataSet> dataSetQueryWrapper = new QueryWrapper<>();
        dataSetQueryWrapper.eq("Pid",id);
        return this.remove(dataSetQueryWrapper);
    }

    @Override
    public List<DataSet> findSetById(String id) {
        return this.lambdaQuery().eq(DataSet::getPid,id).list();
    }
}
