package cn.stylefeng.guns.modular.sc.serialNumbersConf.service.impl;
import cn.stylefeng.guns.base.pojo.page.LayuiPageFactory;
import cn.stylefeng.guns.base.pojo.page.LayuiPageInfo;
import cn.stylefeng.guns.modular.sc.serialNumbersConf.entity.SerialNumbersConf;
import cn.stylefeng.guns.modular.sc.serialNumbersConf.mapper.SerialNumbersConfMapper;
import cn.stylefeng.guns.modular.sc.serialNumbersConf.model.params.SerialNumbersConfParam;
import cn.stylefeng.guns.modular.sc.serialNumbersConf.model.result.SerialNumbersConfResult;
import cn.stylefeng.guns.modular.sc.serialNumbersConf.service.SerialNumbersConfService;
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-03-25
*/
@Service
public class SerialNumbersConfServiceImpl extends ServiceImpl implements SerialNumbersConfService {
@Override
public void add(SerialNumbersConfParam param){
SerialNumbersConf entity = getEntity(param);
this.save(entity);
}
@Override
public void delete(SerialNumbersConfParam param){
this.removeById(getKey(param));
}
@Override
public void update(SerialNumbersConfParam param){
SerialNumbersConf oldEntity = getOldEntity(param);
SerialNumbersConf newEntity = getEntity(param);
ToolUtil.copyProperties(newEntity, oldEntity);
this.updateById(newEntity);
}
@Override
public SerialNumbersConfResult findBySpec(SerialNumbersConfParam param){
return null;
}
@Override
public List findListBySpec(SerialNumbersConfParam param){
return this.baseMapper.customList(param);
}
@Override
public LayuiPageInfo findPageBySpec(SerialNumbersConfParam param){
Page pageContext = getPageContext();
IPage page = this.baseMapper.customPageList(pageContext, param);
return LayuiPageFactory.createPageInfo(page);
}
private Serializable getKey(SerialNumbersConfParam param){
return param.getId();
}
private Page getPageContext() {
return LayuiPageFactory.defaultPage();
}
private SerialNumbersConf getOldEntity(SerialNumbersConfParam param) {
return this.getById(getKey(param));
}
private SerialNumbersConf getEntity(SerialNumbersConfParam param) {
SerialNumbersConf entity = new SerialNumbersConf();
ToolUtil.copyProperties(param, entity);
return entity;
}
}