提交 | 用户 | 时间
|
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.Task; |
|
7 |
import cn.stylefeng.guns.workflow.modular.mapper.TaskWaitingMapper; |
|
8 |
import cn.stylefeng.guns.workflow.modular.model.params.TaskParam; |
|
9 |
import cn.stylefeng.guns.workflow.modular.model.result.TaskResult; |
|
10 |
import cn.stylefeng.guns.workflow.modular.service.TaskWaitingService; |
|
11 |
import cn.stylefeng.roses.core.util.ToolUtil; |
|
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.HashMap; |
|
18 |
import java.util.List; |
|
19 |
import java.util.Map; |
|
20 |
|
|
21 |
/** |
|
22 |
* <p> |
|
23 |
* 服务实现类 |
|
24 |
* </p> |
|
25 |
* |
|
26 |
* @author fengshuonan |
|
27 |
* @since 2019-08-19 |
|
28 |
*/ |
|
29 |
@Service |
|
30 |
public class TaskWaitingServiceImpl extends ServiceImpl<TaskWaitingMapper, Task> implements TaskWaitingService { |
|
31 |
|
|
32 |
@Override |
|
33 |
public void add(TaskParam param) { |
|
34 |
Task entity = getEntity(param); |
|
35 |
this.save(entity); |
|
36 |
} |
|
37 |
|
|
38 |
@Override |
|
39 |
public String getUserRoleString() { |
|
40 |
String account = LoginContextHolder.getContext().getUser().getAccount(); |
|
41 |
String userRoleString = this.baseMapper.getUserRoleString(account); |
|
42 |
StringBuilder result = new StringBuilder("("); |
|
43 |
|
|
44 |
if (ToolUtil.isEmpty(userRoleString)) { |
|
45 |
return String.valueOf(result.append("''").append(")")); |
|
46 |
} |
|
47 |
|
|
48 |
if (userRoleString.contains(",")) { |
|
49 |
String[] split = userRoleString.trim().split(","); |
|
50 |
for (int i = 0; i < split.length; i++) { |
|
51 |
if (i < split.length - 1) { |
|
52 |
result.append("'").append(split[i]).append("'").append(","); |
|
53 |
} else { |
|
54 |
result.append("'").append(split[i]).append("'").append(")"); |
|
55 |
} |
|
56 |
} |
|
57 |
return String.valueOf(result); |
|
58 |
} else if (ToolUtil.isNotEmpty(userRoleString)) { |
|
59 |
return String.valueOf(result.append("'").append(userRoleString).append("'").append(")")); |
|
60 |
} |
|
61 |
return "('')"; |
|
62 |
} |
|
63 |
|
|
64 |
@Override |
|
65 |
public void delete(TaskParam param) { |
|
66 |
this.removeById(getKey(param)); |
|
67 |
} |
|
68 |
|
|
69 |
@Override |
|
70 |
public void update(TaskParam param) { |
|
71 |
Task oldEntity = getOldEntity(param); |
|
72 |
Task newEntity = getEntity(param); |
|
73 |
ToolUtil.copyProperties(newEntity, oldEntity); |
|
74 |
this.updateById(newEntity); |
|
75 |
} |
|
76 |
|
|
77 |
@Override |
|
78 |
public TaskResult findBySpec(TaskParam param) { |
|
79 |
return null; |
|
80 |
} |
|
81 |
|
|
82 |
@Override |
|
83 |
public List<TaskResult> findListBySpec(TaskParam param) { |
|
84 |
return null; |
|
85 |
} |
|
86 |
|
|
87 |
@Override |
|
88 |
public LayuiPageInfo findPageBySpec(TaskParam param) { |
|
89 |
|
|
90 |
HashMap<String, Object> paramMap = new HashMap<>(); |
|
91 |
paramMap.put("keywords", param.getKeywords()); |
|
92 |
paramMap.put("lastStart", param.getLastStart()); |
|
93 |
paramMap.put("lastEnd", param.getLastEnd()); |
|
94 |
|
|
95 |
paramMap.put("USERNAME", LoginContextHolder.getContext().getUser().getAccount()); |
|
96 |
String userRoleString = this.getUserRoleString(); |
|
97 |
paramMap.put("RNUMBERS", userRoleString); |
|
98 |
|
|
99 |
Page pageContext = getPageContext(); |
|
100 |
List<Map<String, Object>> maps = this.baseMapper.datalistPage(pageContext, paramMap); |
|
101 |
pageContext.setRecords(maps); |
|
102 |
|
|
103 |
return LayuiPageFactory.createPageInfo(pageContext); |
|
104 |
} |
|
105 |
|
|
106 |
private Serializable getKey(TaskParam param) { |
|
107 |
return param.getId(); |
|
108 |
} |
|
109 |
|
|
110 |
private Page getPageContext() { |
|
111 |
return LayuiPageFactory.defaultPage(); |
|
112 |
} |
|
113 |
|
|
114 |
private Task getOldEntity(TaskParam param) { |
|
115 |
return this.getById(getKey(param)); |
|
116 |
} |
|
117 |
|
|
118 |
private Task getEntity(TaskParam param) { |
|
119 |
Task entity = new Task(); |
|
120 |
ToolUtil.copyProperties(param, entity); |
|
121 |
return entity; |
|
122 |
} |
|
123 |
|
|
124 |
} |