package cn.stylefeng.guns.modular.zsx.bs.productRouteChildInfo.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.productBomChildInfo.entity.ProductBomChildInfo;
import cn.stylefeng.guns.modular.zsx.bs.productRouteChildInfo.entity.ProductRouteChildInfo;
import cn.stylefeng.guns.modular.zsx.bs.productRouteChildInfo.mapper.ProductRouteChildInfoMapper;
import cn.stylefeng.guns.modular.zsx.bs.productRouteChildInfo.model.params.ProductRouteChildInfoParam;
import cn.stylefeng.guns.modular.zsx.bs.productRouteChildInfo.model.result.ProductRouteChildInfoResult;
import cn.stylefeng.guns.modular.zsx.bs.productRouteChildInfo.service.ProductRouteChildInfoService;
import cn.stylefeng.roses.core.util.ToolUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
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-24
*/
@Service
public class ProductRouteChildInfoServiceImpl extends ServiceImpl implements ProductRouteChildInfoService {
@Override
public void add(ProductRouteChildInfoParam param){
ProductRouteChildInfo entity = getEntity(param);
this.save(entity);
}
@Override
public void delete(ProductRouteChildInfoParam param){
this.removeById(getKey(param));
}
@Override
public void update(ProductRouteChildInfoParam param){
ProductRouteChildInfo oldEntity = getOldEntity(param);
ProductRouteChildInfo newEntity = getEntity(param);
ToolUtil.copyProperties(newEntity, oldEntity);
this.updateById(newEntity);
}
@Override
public ProductRouteChildInfoResult findBySpec(ProductRouteChildInfoParam param){
return null;
}
@Override
public List findListBySpec(ProductRouteChildInfoParam param){
return null;
}
@Override
public LayuiPageInfo findPageBySpec(ProductRouteChildInfoParam param){
Page pageContext = getPageContext();
IPage page = this.baseMapper.customPageList(pageContext, param);
return LayuiPageFactory.createPageInfo(page);
}
@Override
public void deleteBomChildByBomCode(String routeCode) {
this.baseMapper.delete(new QueryWrapper().eq("route_code",routeCode));
}
private Serializable getKey(ProductRouteChildInfoParam param){
return param.getId();
}
private Page getPageContext() {
return LayuiPageFactory.defaultPage();
}
private ProductRouteChildInfo getOldEntity(ProductRouteChildInfoParam param) {
return this.getById(getKey(param));
}
private ProductRouteChildInfo getEntity(ProductRouteChildInfoParam param) {
ProductRouteChildInfo entity = new ProductRouteChildInfo();
ToolUtil.copyProperties(param, entity);
return entity;
}
}