package cn.stylefeng.guns.modular.om.productionOrderRecords.service.impl;
import cn.stylefeng.guns.base.pojo.page.LayuiPageFactory;
import cn.stylefeng.guns.base.pojo.page.LayuiPageInfo;
import cn.stylefeng.guns.modular.om.productionOrderRecords.entity.ProductionOrderRecords;
import cn.stylefeng.guns.modular.om.productionOrderRecords.mapper.ProductionOrderRecordsMapper;
import cn.stylefeng.guns.modular.om.productionOrderRecords.model.params.ProductionOrderRecordsParam;
import cn.stylefeng.guns.modular.om.productionOrderRecords.model.result.ProductionOrderRecordsResult;
import cn.stylefeng.guns.modular.om.productionOrderRecords.service.ProductionOrderRecordsService;
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 cl
* @since 2022-10-27
*/
@Service
public class ProductionOrderRecordsServiceImpl extends ServiceImpl implements ProductionOrderRecordsService {
@Override
public void add(ProductionOrderRecordsParam param){
ProductionOrderRecords entity = getEntity(param);
this.save(entity);
}
@Override
public void delete(ProductionOrderRecordsParam param){
this.removeById(getKey(param));
}
@Override
public void update(ProductionOrderRecordsParam param){
ProductionOrderRecords oldEntity = getOldEntity(param);
ProductionOrderRecords newEntity = getEntity(param);
ToolUtil.copyProperties(newEntity, oldEntity);
this.updateById(newEntity);
}
@Override
public ProductionOrderRecordsResult findBySpec(ProductionOrderRecordsParam param){
return null;
}
@Override
public List findListBySpec(ProductionOrderRecordsParam param){
return null;
}
@Override
public LayuiPageInfo findPageBySpec(ProductionOrderRecordsParam param){
Page pageContext = getPageContext();
IPage page = this.baseMapper.customPageList(pageContext, param);
return LayuiPageFactory.createPageInfo(page);
}
private Serializable getKey(ProductionOrderRecordsParam param){
return param.getId();
}
private Page getPageContext() {
return LayuiPageFactory.defaultPage();
}
private ProductionOrderRecords getOldEntity(ProductionOrderRecordsParam param) {
return this.getById(getKey(param));
}
private ProductionOrderRecords getEntity(ProductionOrderRecordsParam param) {
ProductionOrderRecords entity = new ProductionOrderRecords();
ToolUtil.copyProperties(param, entity);
return entity;
}
}