cl
2024-01-19 e0fac38b26845f25de479783e0c76cf12a5311e0
提交 | 用户 | 时间
71e81e 1 package cn.stylefeng.guns.modular.sm.scrapCategoryRecord.service.impl;
2
3 import cn.stylefeng.guns.base.auth.context.LoginContextHolder;
4 import cn.stylefeng.guns.base.pojo.page.LayuiPageFactory;
5 import cn.stylefeng.guns.base.pojo.page.LayuiPageInfo;
6 import cn.stylefeng.guns.modular.sm.scrapCategoryRecord.entity.ScrapCategoryRecord;
7 import cn.stylefeng.guns.modular.sm.scrapCategoryRecord.mapper.ScrapCategoryRecordMapper;
8 import cn.stylefeng.guns.modular.sm.scrapCategoryRecord.model.params.ScrapCategoryRecordParam;
9 import cn.stylefeng.guns.modular.sm.scrapCategoryRecord.model.result.ScrapCategoryRecordResult;
10 import  cn.stylefeng.guns.modular.sm.scrapCategoryRecord.service.ScrapCategoryRecordService;
11 import cn.stylefeng.roses.core.util.ToolUtil;
12 import com.baomidou.mybatisplus.core.metadata.IPage;
13 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
14 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
15 import org.springframework.stereotype.Service;
16
17 import java.io.Serializable;
18 import java.util.List;
19
20 /**
21  * <p>
22  * 报废记录 服务实现类
23  * </p>
24  *
25  * @author ruimin
26  * @since 2023-02-23
27  */
28 @Service
29 public class ScrapCategoryRecordServiceImpl extends ServiceImpl<ScrapCategoryRecordMapper, ScrapCategoryRecord> implements ScrapCategoryRecordService {
30
31     @Override
32     public void add(ScrapCategoryRecordParam param){
33         param.setOperateUser(LoginContextHolder.getContext().getUser().getName());
34         ScrapCategoryRecord entity = getEntity(param);
35         this.save(entity);
36     }
37
38     @Override
39     public void delete(ScrapCategoryRecordParam param){
40         this.removeById(getKey(param));
41     }
42
43     @Override
44     public void update(ScrapCategoryRecordParam param){
45         ScrapCategoryRecord oldEntity = getOldEntity(param);
46         ScrapCategoryRecord newEntity = getEntity(param);
47         ToolUtil.copyProperties(newEntity, oldEntity);
48         this.updateById(newEntity);
49     }
50
51     @Override
52     public ScrapCategoryRecordResult findBySpec(ScrapCategoryRecordParam param){
53         return null;
54     }
55
56     @Override
57     public List<ScrapCategoryRecordResult> findListBySpec(ScrapCategoryRecordParam param){
58         return null;
59     }
60
61     @Override
62     public LayuiPageInfo findPageBySpec(ScrapCategoryRecordParam param){
63         Page pageContext = getPageContext();
64         IPage page = this.baseMapper.customPageList(pageContext, param);
65         return LayuiPageFactory.createPageInfo(page);
66     }
67
68     @Override
69     public Integer getScrapQuantity() {
70         return baseMapper.getScrapQuantity();
71     }
72
73     @Override
74     public Integer getScrapQuantityWeek() {
75         return baseMapper.getScrapQuantityWeek();
76     }
77
78     private Serializable getKey(ScrapCategoryRecordParam param){
79         return param.getId();
80     }
81
82     private Page getPageContext() {
83         return LayuiPageFactory.defaultPage();
84     }
85
86     private ScrapCategoryRecord getOldEntity(ScrapCategoryRecordParam param) {
87         return this.getById(getKey(param));
88     }
89
90     private ScrapCategoryRecord getEntity(ScrapCategoryRecordParam param) {
91         ScrapCategoryRecord entity = new ScrapCategoryRecord();
92         ToolUtil.copyProperties(param, entity);
93         return entity;
94     }
95
96 }