懒羊羊
2023-08-30 1ac2bc1590406d9babec036e154d8d08f34a6aa1
提交 | 用户 | 时间
1ac2bc 1 package cn.stylefeng.guns.modular.zsx.bs.workshop.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.zsx.bs.workshop.entity.WorkshopInfo;
7 import cn.stylefeng.guns.modular.zsx.bs.workshop.mapper.WorkshopInfoMapper;
8 import cn.stylefeng.guns.modular.zsx.bs.workshop.model.params.WorkshopInfoParam;
9 import cn.stylefeng.guns.modular.zsx.bs.workshop.model.result.WorkshopInfoResult;
10 import  cn.stylefeng.guns.modular.zsx.bs.workshop.service.WorkshopInfoService;
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-08-19
27  */
28 @Service
29 public class WorkshopInfoServiceImpl extends ServiceImpl<WorkshopInfoMapper, WorkshopInfo> implements WorkshopInfoService {
30
31     @Override
32     public void add(WorkshopInfoParam param){
33         param.setCreateUser(LoginContextHolder.getContext().getUser().getName());
34         WorkshopInfo entity = getEntity(param);
35         this.save(entity);
36     }
37
38     @Override
39     public void delete(WorkshopInfoParam param){
40         this.removeById(getKey(param));
41     }
42
43     @Override
44     public void update(WorkshopInfoParam param){
45         param.setUpdateUser(LoginContextHolder.getContext().getUser().getName());
46         WorkshopInfo oldEntity = getOldEntity(param);
47         WorkshopInfo newEntity = getEntity(param);
48         ToolUtil.copyProperties(newEntity, oldEntity);
49         this.updateById(newEntity);
50     }
51
52     @Override
53     public WorkshopInfoResult findBySpec(WorkshopInfoParam param){
54         return null;
55     }
56
57     @Override
58     public List<WorkshopInfoResult> findListBySpec(WorkshopInfoParam param){
59         return null;
60     }
61
62     @Override
63     public LayuiPageInfo findPageBySpec(WorkshopInfoParam param){
64         Page pageContext = getPageContext();
65         IPage page = this.baseMapper.customPageList(pageContext, param);
66         return LayuiPageFactory.createPageInfo(page);
67     }
68
69     private Serializable getKey(WorkshopInfoParam param){
70         return param.getId();
71     }
72
73     private Page getPageContext() {
74         return LayuiPageFactory.defaultPage();
75     }
76
77     private WorkshopInfo getOldEntity(WorkshopInfoParam param) {
78         return this.getById(getKey(param));
79     }
80
81     private WorkshopInfo getEntity(WorkshopInfoParam param) {
82         WorkshopInfo entity = new WorkshopInfo();
83         ToolUtil.copyProperties(param, entity);
84         return entity;
85     }
86
87 }