package cn.stylefeng.guns.modular.zsx.bs.formula.service.impl; import cn.stylefeng.guns.base.pojo.page.LayuiPageFactory; import cn.stylefeng.guns.base.pojo.page.LayuiPageInfo; import cn.stylefeng.guns.modular.zsx.bs.formula.entity.FormulaInfo; import cn.stylefeng.guns.modular.zsx.bs.formula.mapper.FormulaInfoMapper; import cn.stylefeng.guns.modular.zsx.bs.formula.model.params.FormulaInfoParam; import cn.stylefeng.guns.modular.zsx.bs.formula.model.result.FormulaInfoResult; import cn.stylefeng.guns.modular.zsx.bs.formula.service.FormulaInfoService; 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 ruimin * @since 2023-10-09 */ @Service public class FormulaInfoServiceImpl extends ServiceImpl implements FormulaInfoService { @Override public void add(FormulaInfoParam param){ FormulaInfo entity = getEntity(param); this.save(entity); } @Override public void delete(FormulaInfoParam param){ this.removeById(getKey(param)); } @Override public void update(FormulaInfoParam param){ FormulaInfo oldEntity = getOldEntity(param); FormulaInfo newEntity = getEntity(param); ToolUtil.copyProperties(newEntity, oldEntity); this.updateById(newEntity); } @Override public FormulaInfoResult findBySpec(FormulaInfoParam param){ return null; } @Override public List findListBySpec(FormulaInfoParam param){ return null; } @Override public LayuiPageInfo findPageBySpec(FormulaInfoParam param){ Page pageContext = getPageContext(); IPage page = this.baseMapper.customPageList(pageContext, param); return LayuiPageFactory.createPageInfo(page); } private Serializable getKey(FormulaInfoParam param){ return param.getId(); } private Page getPageContext() { return LayuiPageFactory.defaultPage(); } private FormulaInfo getOldEntity(FormulaInfoParam param) { return this.getById(getKey(param)); } private FormulaInfo getEntity(FormulaInfoParam param) { FormulaInfo entity = new FormulaInfo(); ToolUtil.copyProperties(param, entity); return entity; } }