yantian yue
2023-10-18 69fbaaa1a5fd16b05953e750ea7fcc3e18e3a27c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
package cn.stylefeng.guns.modular.zsx.bs.opInfo.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.zsx.bs.opInfo.entity.OpInfo;
import cn.stylefeng.guns.modular.zsx.bs.opInfo.mapper.OpInfoMapper;
import cn.stylefeng.guns.modular.zsx.bs.opInfo.model.params.OpInfoParam;
import cn.stylefeng.guns.modular.zsx.bs.opInfo.model.result.OpInfoResult;
import  cn.stylefeng.guns.modular.zsx.bs.opInfo.service.OpInfoService;
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;
 
/**
 * <p>
 * 工序信息 服务实现类
 * </p>
 *
 * @author ruimin
 * @since 2023-08-24
 */
@Service
public class OpInfoServiceImpl extends ServiceImpl<OpInfoMapper, OpInfo> implements OpInfoService {
 
    @Override
    public void add(OpInfoParam param){
        param.setCreateUser(LoginContextHolder.getContext().getUser().getName());
        OpInfo entity = getEntity(param);
        this.save(entity);
    }
 
    @Override
    public void delete(OpInfoParam param){
        this.removeById(getKey(param));
    }
 
    @Override
    public void update(OpInfoParam param){
        param.setUpdateUser(LoginContextHolder.getContext().getUser().getName());
        OpInfo oldEntity = getOldEntity(param);
        OpInfo newEntity = getEntity(param);
        ToolUtil.copyProperties(newEntity, oldEntity);
        this.updateById(newEntity);
    }
 
    @Override
    public OpInfoResult findBySpec(OpInfoParam param){
        return null;
    }
 
    @Override
    public List<OpInfoResult> findListBySpec(OpInfoParam param){
        return null;
    }
 
    @Override
    public LayuiPageInfo findPageBySpec(OpInfoParam param){
        Page pageContext = getPageContext();
        IPage page = this.baseMapper.customPageList(pageContext, param);
        return LayuiPageFactory.createPageInfo(page);
    }
 
    private Serializable getKey(OpInfoParam param){
        return param.getId();
    }
 
    private Page getPageContext() {
        return LayuiPageFactory.defaultPage();
    }
 
    private OpInfo getOldEntity(OpInfoParam param) {
        return this.getById(getKey(param));
    }
 
    private OpInfo getEntity(OpInfoParam param) {
        OpInfo entity = new OpInfo();
        ToolUtil.copyProperties(param, entity);
        return entity;
    }
 
}