package com.njcn.energy.service.impl;

import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njcn.common.pojo.enums.common.DataStateEnum;
import com.njcn.energy.mapper.DataMouldMapper;
import com.njcn.energy.pojo.param.DataModelParam;
import com.njcn.energy.pojo.po.DataMould;
import com.njcn.energy.pojo.po.EleLine;
import com.njcn.energy.service.IDevModelService;
import org.springframework.stereotype.Service;

/**
 * 类的介绍：
 *
 * @author xuyang
 * @version 1.0.0
 * @createTime 2022/3/8 20:41
 */
@Service
public class DevModelServiceImpl extends ServiceImpl<DataMouldMapper, DataMould> implements IDevModelService {

    @Override
    public DataMould addDataMould(DataModelParam dataModelParam) {
        DataMould dataMould = new DataMould();
        BeanUtil.copyProperties(dataModelParam,dataMould);
        dataMould.setState(DataStateEnum.ENABLE.getCode());
        this.save(dataMould);
        return dataMould;
    }

    @Override
    public boolean deleteById(String id) {
        return this.removeById(id);
    }

    @Override
    public DataMould findMould(String name, String version, String time) {
        return this.lambdaQuery().eq(DataMould::getName,name).eq(DataMould::getVersion,version).eq(DataMould::getTime,time).one();
    }
}
