long
2023-09-02 e379948bb83ebcc9ce0c467a7b970f74bc00e9a1
提交 | 用户 | 时间
71e81e 1 package cn.stylefeng.guns.modular.bs.equipmentInfo.service.impl;
2
3 import cn.stylefeng.guns.base.pojo.page.LayuiPageFactory;
4 import cn.stylefeng.guns.base.pojo.page.LayuiPageInfo;
5 import cn.stylefeng.guns.modular.bs.equipmentInfo.entity.EquipmentInfo;
6 import cn.stylefeng.guns.modular.bs.equipmentInfo.mapper.EquipmentInfoMapper;
7 import cn.stylefeng.guns.modular.bs.equipmentInfo.model.params.EquipmentInfoParam;
8 import cn.stylefeng.guns.modular.bs.equipmentInfo.model.result.EquipmentInfoResult;
9 import  cn.stylefeng.guns.modular.bs.equipmentInfo.service.EquipmentInfoService;
10 import cn.stylefeng.roses.core.util.ToolUtil;
11 import com.baomidou.mybatisplus.core.metadata.IPage;
12 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
13 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
14 import org.springframework.stereotype.Service;
15
16 import java.io.Serializable;
17 import java.util.List;
18
19 /**
20  * <p>
21  * 设备档案 服务实现类
22  * </p>
23  *
24  * @author cl
25  * @since 2022-10-28
26  */
27 @Service
28 public class EquipmentInfoServiceImpl extends ServiceImpl<EquipmentInfoMapper, EquipmentInfo> implements EquipmentInfoService {
29
30     @Override
31     public void add(EquipmentInfoParam param){
32         EquipmentInfo entity = getEntity(param);
33         this.save(entity);
34     }
35
36     @Override
37     public void delete(EquipmentInfoParam param){
38         this.removeById(getKey(param));
39     }
40
41     @Override
42     public void update(EquipmentInfoParam param){
43         EquipmentInfo oldEntity = getOldEntity(param);
44         EquipmentInfo newEntity = getEntity(param);
45         ToolUtil.copyProperties(newEntity, oldEntity);
46         this.updateById(newEntity);
47     }
48
49     @Override
50     public EquipmentInfoResult findBySpec(EquipmentInfoParam param){
51         return null;
52     }
53
54     @Override
55     public List<EquipmentInfoResult> findListBySpec(EquipmentInfoParam param){
56         return this.baseMapper.customList(param);
57     }
58
59     @Override
60     public LayuiPageInfo findPageBySpec(EquipmentInfoParam param){
61         Page pageContext = getPageContext();
62         IPage page = this.baseMapper.customPageList(pageContext, param);
63         return LayuiPageFactory.createPageInfo(page);
64     }
65
66     @Override
67     public List<EquipmentInfoResult> exportTable(EquipmentInfoParam param) {
68         return this.baseMapper.customList(param);
69     }
70
71     private Serializable getKey(EquipmentInfoParam param){
72         return param.getId();
73     }
74
75     private Page getPageContext() {
76         return LayuiPageFactory.defaultPage();
77     }
78
79     private EquipmentInfo getOldEntity(EquipmentInfoParam param) {
80         return this.getById(getKey(param));
81     }
82
83     private EquipmentInfo getEntity(EquipmentInfoParam param) {
84         EquipmentInfo entity = new EquipmentInfo();
85         ToolUtil.copyProperties(param, entity);
86         return entity;
87     }
88
89 }