package cn.stylefeng.guns.modular.zsx.bs.productBomChildInfo.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.productBomChildInfo.mapper.ProductBomChildInfoMapper;
import cn.stylefeng.guns.modular.zsx.bs.productBomChildInfo.model.params.ProductBomChildInfoParam;
import cn.stylefeng.guns.modular.zsx.bs.productBomChildInfo.model.result.ProductBomChildInfoResult;
import cn.stylefeng.guns.modular.zsx.bs.productBomChildInfo.service.ProductBomChildInfoService;
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;
/**
*
* 基础BOM 服务实现类
*
*
* @author ruimin
* @since 2023-08-24
*/
@Service
public class ProductBomChildInfoServiceImpl extends ServiceImpl implements ProductBomChildInfoService {
@Override
public void add(ProductBomChildInfoParam param){
ProductBomChildInfo entity = getEntity(param);
this.save(entity);
}
@Override
public void delete(ProductBomChildInfoParam param){
this.removeById(getKey(param));
}
@Override
public void update(ProductBomChildInfoParam param){
ProductBomChildInfo oldEntity = getOldEntity(param);
ProductBomChildInfo newEntity = getEntity(param);
ToolUtil.copyProperties(newEntity, oldEntity);
this.updateById(newEntity);
}
@Override
public ProductBomChildInfoResult findBySpec(ProductBomChildInfoParam param){
return null;
}
@Override
public List findListBySpec(ProductBomChildInfoParam param){
return null;
}
@Override
public LayuiPageInfo findPageBySpec(ProductBomChildInfoParam param){
Page pageContext = getPageContext();
IPage page = this.baseMapper.customPageList(pageContext, param);
return LayuiPageFactory.createPageInfo(page);
}
@Override
public void deleteBomChildByBomCode(String bomCode) {
this.baseMapper.delete(new QueryWrapper().eq("bom_code",bomCode));
}
private Serializable getKey(ProductBomChildInfoParam param){
return param.getId();
}
private Page getPageContext() {
return LayuiPageFactory.defaultPage();
}
private ProductBomChildInfo getOldEntity(ProductBomChildInfoParam param) {
return this.getById(getKey(param));
}
private ProductBomChildInfo getEntity(ProductBomChildInfoParam param) {
ProductBomChildInfo entity = new ProductBomChildInfo();
ToolUtil.copyProperties(param, entity);
return entity;
}
}