package cn.stylefeng.guns.modular.zsx.pm.salesOrderChild.service.impl;
import cn.stylefeng.guns.base.pojo.page.LayuiPageFactory;
import cn.stylefeng.guns.base.pojo.page.LayuiPageInfo;
import cn.stylefeng.guns.modular.zsx.pm.salesOrderChild.entity.SalesOrderChild;
import cn.stylefeng.guns.modular.zsx.pm.salesOrderChild.mapper.SalesOrderChildMapper;
import cn.stylefeng.guns.modular.zsx.pm.salesOrderChild.model.params.SalesOrderChildParam;
import cn.stylefeng.guns.modular.zsx.pm.salesOrderChild.model.result.SalesOrderChildResult;
import cn.stylefeng.guns.modular.zsx.pm.salesOrderChild.service.SalesOrderChildService;
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-08-29
*/
@Service
public class SalesOrderChildServiceImpl extends ServiceImpl implements SalesOrderChildService {
@Override
public void add(SalesOrderChildParam param){
SalesOrderChild entity = getEntity(param);
this.save(entity);
}
@Override
public void delete(SalesOrderChildParam param){
this.removeById(getKey(param));
}
@Override
public void update(SalesOrderChildParam param){
SalesOrderChild oldEntity = getOldEntity(param);
SalesOrderChild newEntity = getEntity(param);
ToolUtil.copyProperties(newEntity, oldEntity);
this.updateById(newEntity);
}
@Override
public SalesOrderChildResult findBySpec(SalesOrderChildParam param){
return null;
}
@Override
public List findListBySpec(SalesOrderChildParam param){
return null;
}
@Override
public LayuiPageInfo findPageBySpec(SalesOrderChildParam param){
Page pageContext = getPageContext();
IPage page = this.baseMapper.customPageList(pageContext, param);
return LayuiPageFactory.createPageInfo(page);
}
@Override
public Integer getPlanNumberTotal(SalesOrderChildParam salesOrderChildParam) {
return this.baseMapper.getPlanNumberTotal(salesOrderChildParam);
}
private Serializable getKey(SalesOrderChildParam param){
return param.getId();
}
private Page getPageContext() {
return LayuiPageFactory.defaultPage();
}
private SalesOrderChild getOldEntity(SalesOrderChildParam param) {
return this.getById(getKey(param));
}
private SalesOrderChild getEntity(SalesOrderChildParam param) {
SalesOrderChild entity = new SalesOrderChild();
ToolUtil.copyProperties(param, entity);
return entity;
}
}