package cn.stylefeng.guns.modular.bs.collectionParamConf.service.impl; import cn.stylefeng.guns.base.pojo.page.LayuiPageFactory; import cn.stylefeng.guns.base.pojo.page.LayuiPageInfo; import cn.stylefeng.guns.modular.bs.collectionParamConf.entity.CollectionParamConf; import cn.stylefeng.guns.modular.bs.collectionParamConf.mapper.CollectionParamConfMapper; import cn.stylefeng.guns.modular.bs.collectionParamConf.model.params.CollectionParamConfParam; import cn.stylefeng.guns.modular.bs.collectionParamConf.model.result.CollectionParamConfResult; import cn.stylefeng.guns.modular.bs.collectionParamConf.service.CollectionParamConfService; import cn.stylefeng.roses.core.util.ToolUtil; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springframework.stereotype.Service; import java.io.Serializable; import java.util.List; /** *

* 采集参数配置 服务实现类 *

* * @author zrm * @since 2023-02-11 */ @Service public class CollectionParamConfServiceImpl extends ServiceImpl implements CollectionParamConfService { @Override public void add(CollectionParamConfParam param){ CollectionParamConf entity = getEntity(param); this.save(entity); } @Override public void delete(CollectionParamConfParam param){ this.removeById(getKey(param)); } @Override public void update(CollectionParamConfParam param){ CollectionParamConf oldEntity = getOldEntity(param); CollectionParamConf newEntity = getEntity(param); ToolUtil.copyProperties(newEntity, oldEntity); this.updateById(newEntity); } @Override public CollectionParamConfResult findBySpec(CollectionParamConfParam param){ return null; } @Override public List findListBySpec(CollectionParamConfParam param){ return this.baseMapper.customList(param); } @Override public LayuiPageInfo findPageBySpec(CollectionParamConfParam param){ Page pageContext = getPageContext(); IPage page = this.baseMapper.customPageList(pageContext, param); return LayuiPageFactory.createPageInfo(page); } private Serializable getKey(CollectionParamConfParam param){ return param.getId(); } private Page getPageContext() { return LayuiPageFactory.defaultPage(); } private CollectionParamConf getOldEntity(CollectionParamConfParam param) { return this.getById(getKey(param)); } private CollectionParamConf getEntity(CollectionParamConfParam param) { CollectionParamConf entity = new CollectionParamConf(); ToolUtil.copyProperties(param, entity); return entity; } }