懒羊羊
2023-11-14 8286c62256f23bc2367a6729c0f46f84215e380b
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
package cn.stylefeng.guns.modular.bs.workshopInfo.service.impl;
 
import cn.stylefeng.guns.base.pojo.page.LayuiPageFactory;
import cn.stylefeng.guns.base.pojo.page.LayuiPageInfo;
import cn.stylefeng.guns.modular.bs.workshopInfo.entity.WorkshopInfo;
import cn.stylefeng.guns.modular.bs.workshopInfo.mapper.WorkshopInfoMapper;
import cn.stylefeng.guns.modular.bs.workshopInfo.model.params.WorkshopInfoParam;
import cn.stylefeng.guns.modular.bs.workshopInfo.model.result.WorkshopInfoResult;
import  cn.stylefeng.guns.modular.bs.workshopInfo.service.WorkshopInfoService;
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 cl
 * @since 2022-10-28
 */
@Service
public class WorkshopInfoServiceImpl extends ServiceImpl<WorkshopInfoMapper, WorkshopInfo> implements WorkshopInfoService {
 
    @Override
    public void add(WorkshopInfoParam param){
        WorkshopInfo entity = getEntity(param);
        this.save(entity);
    }
 
    @Override
    public void delete(WorkshopInfoParam param){
        this.removeById(getKey(param));
    }
 
    @Override
    public void update(WorkshopInfoParam param){
        WorkshopInfo oldEntity = getOldEntity(param);
        WorkshopInfo newEntity = getEntity(param);
        ToolUtil.copyProperties(newEntity, oldEntity);
        this.updateById(newEntity);
    }
 
    @Override
    public WorkshopInfoResult findBySpec(WorkshopInfoParam param){
        return null;
    }
 
    @Override
    public List<WorkshopInfoResult> findListBySpec(WorkshopInfoParam param){
        return null;
    }
 
    @Override
    public LayuiPageInfo findPageBySpec(WorkshopInfoParam param){
        Page pageContext = getPageContext();
        IPage page = this.baseMapper.customPageList(pageContext, param);
        return LayuiPageFactory.createPageInfo(page);
    }
 
    private Serializable getKey(WorkshopInfoParam param){
        return param.getId();
    }
 
    private Page getPageContext() {
        return LayuiPageFactory.defaultPage();
    }
 
    private WorkshopInfo getOldEntity(WorkshopInfoParam param) {
        return this.getById(getKey(param));
    }
 
    private WorkshopInfo getEntity(WorkshopInfoParam param) {
        WorkshopInfo entity = new WorkshopInfo();
        ToolUtil.copyProperties(param, entity);
        return entity;
    }
 
}