package cn.stylefeng.guns.modular.sm.scrapCategoryRecord.service.impl;
import cn.stylefeng.guns.base.auth.context.LoginContextHolder;
import cn.stylefeng.guns.base.pojo.page.LayuiPageFactory;
import cn.stylefeng.guns.base.pojo.page.LayuiPageInfo;
import cn.stylefeng.guns.modular.sm.scrapCategoryRecord.entity.ScrapCategoryRecord;
import cn.stylefeng.guns.modular.sm.scrapCategoryRecord.mapper.ScrapCategoryRecordMapper;
import cn.stylefeng.guns.modular.sm.scrapCategoryRecord.model.params.ScrapCategoryRecordParam;
import cn.stylefeng.guns.modular.sm.scrapCategoryRecord.model.result.ScrapCategoryRecordResult;
import cn.stylefeng.guns.modular.sm.scrapCategoryRecord.service.ScrapCategoryRecordService;
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-02-23
*/
@Service
public class ScrapCategoryRecordServiceImpl extends ServiceImpl implements ScrapCategoryRecordService {
@Override
public void add(ScrapCategoryRecordParam param){
param.setOperateUser(LoginContextHolder.getContext().getUser().getName());
ScrapCategoryRecord entity = getEntity(param);
this.save(entity);
}
@Override
public void delete(ScrapCategoryRecordParam param){
this.removeById(getKey(param));
}
@Override
public void update(ScrapCategoryRecordParam param){
ScrapCategoryRecord oldEntity = getOldEntity(param);
ScrapCategoryRecord newEntity = getEntity(param);
ToolUtil.copyProperties(newEntity, oldEntity);
this.updateById(newEntity);
}
@Override
public ScrapCategoryRecordResult findBySpec(ScrapCategoryRecordParam param){
return null;
}
@Override
public List findListBySpec(ScrapCategoryRecordParam param){
return null;
}
@Override
public LayuiPageInfo findPageBySpec(ScrapCategoryRecordParam param){
Page pageContext = getPageContext();
IPage page = this.baseMapper.customPageList(pageContext, param);
return LayuiPageFactory.createPageInfo(page);
}
@Override
public Integer getScrapQuantity() {
return baseMapper.getScrapQuantity();
}
@Override
public Integer getScrapQuantityWeek() {
return baseMapper.getScrapQuantityWeek();
}
private Serializable getKey(ScrapCategoryRecordParam param){
return param.getId();
}
private Page getPageContext() {
return LayuiPageFactory.defaultPage();
}
private ScrapCategoryRecord getOldEntity(ScrapCategoryRecordParam param) {
return this.getById(getKey(param));
}
private ScrapCategoryRecord getEntity(ScrapCategoryRecordParam param) {
ScrapCategoryRecord entity = new ScrapCategoryRecord();
ToolUtil.copyProperties(param, entity);
return entity;
}
}