懒羊羊
2023-08-30 1ac2bc1590406d9babec036e154d8d08f34a6aa1
提交 | 用户 | 时间
1ac2bc 1 package cn.stylefeng.guns.workflow.modular.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.workflow.modular.entity.Myleave;
7 import cn.stylefeng.guns.workflow.modular.mapper.MyleaveMapper;
8 import cn.stylefeng.guns.workflow.modular.model.params.MyLeaveParam;
9 import cn.stylefeng.guns.workflow.modular.model.result.MyleaveResult;
10 import cn.stylefeng.guns.workflow.modular.service.MyleaveService;
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.beans.factory.annotation.Autowired;
16 import org.springframework.stereotype.Service;
17
18 import java.io.Serializable;
19 import java.util.List;
20 import java.util.Map;
21
22 /**
23  * <p>
24  * 服务实现类
25  * </p>
26  *
27  * @author fengshuonan
28  * @since 2019-08-20
29  */
30 @Service
31 public class MyleaveServiceImpl extends ServiceImpl<MyleaveMapper, Myleave> implements MyleaveService {
32
33     @Autowired
34     private MyleaveMapper myleaveMapper;
35
36     @Override
37     public void add(MyLeaveParam param) {
38         Myleave entity = getEntity(param);
39         entity.setUsername(LoginContextHolder.getContext().getUser().getAccount());
40         this.myleaveMapper.insert(entity);
41     }
42
43     @Override
44     public void delete(MyLeaveParam param) {
45         this.removeById(getKey(param));
46     }
47
48     @Override
49     public void update(MyLeaveParam param) {
50         Myleave oldEntity = getOldEntity(param);
51         Myleave newEntity = getEntity(param);
52         ToolUtil.copyProperties(newEntity, oldEntity);
53         this.updateById(newEntity);
54     }
55
56     @Override
57     public MyleaveResult findBySpec(MyLeaveParam param) {
58         return null;
59     }
60
61     @Override
62     public List<MyleaveResult> findListBySpec(MyLeaveParam param) {
63         return null;
64     }
65
66     @Override
67     public LayuiPageInfo findPageBySpec(MyLeaveParam param) {
68         Page pageContext = getPageContext();
69         IPage page = this.baseMapper.datalistPage(pageContext, param);
70         return LayuiPageFactory.createPageInfo(page);
71     }
72
73     @Override
74     public void batchDeleteByIds(List<String> ids) {
75         if (ToolUtil.isNotEmpty(ids)) {
76             myleaveMapper.deleteBatchIds(ids);
77         }
78     }
79
80     private Serializable getKey(MyLeaveParam param) {
81         return param.getMyleaveId();
82     }
83
84     private Page getPageContext() {
85         return LayuiPageFactory.defaultPage();
86     }
87
88     private Myleave getOldEntity(MyLeaveParam param) {
89         return this.getById(getKey(param));
90     }
91
92     private Myleave getEntity(MyLeaveParam param) {
93         Myleave entity = new Myleave();
94         ToolUtil.copyProperties(param, entity);
95         return entity;
96     }
97
98     @Override
99     public List<Map<String, Object>> getLeaves() {
100         return myleaveMapper.getLeaves();
101     }
102 }