|
@@ -1,8 +1,12 @@
|
1
|
1
|
package com.ruoyi.postCheck.service.impl;
|
2
|
2
|
|
3
|
3
|
import java.util.List;
|
|
4
|
+import java.util.stream.Collectors;
|
4
|
5
|
|
|
6
|
+import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
|
7
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
5
|
8
|
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
|
9
|
+import com.ruoyi.common.exception.base.BaseException;
|
6
|
10
|
import com.ruoyi.common.utils.DateUtils;
|
7
|
11
|
import org.springframework.beans.factory.annotation.Autowired;
|
8
|
12
|
import org.springframework.stereotype.Service;
|
|
@@ -10,6 +14,7 @@ import com.ruoyi.postCheck.mapper.PostTeamUserMapper;
|
10
|
14
|
import com.ruoyi.postCheck.domain.PostTeamUser;
|
11
|
15
|
import com.ruoyi.postCheck.service.IPostTeamUserService;
|
12
|
16
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
17
|
+import org.springframework.util.CollectionUtils;
|
13
|
18
|
|
14
|
19
|
/**
|
15
|
20
|
* 岗检小组关联成员Service业务层处理
|
|
@@ -18,8 +23,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
18
|
23
|
* @date 2023-12-19
|
19
|
24
|
*/
|
20
|
25
|
@Service
|
21
|
|
-public class PostTeamUserServiceImpl extends ServiceImpl<PostTeamUserMapper, PostTeamUser> implements IPostTeamUserService
|
22
|
|
-{
|
|
26
|
+public class PostTeamUserServiceImpl extends ServiceImpl<PostTeamUserMapper, PostTeamUser> implements IPostTeamUserService {
|
23
|
27
|
@Autowired
|
24
|
28
|
private PostTeamUserMapper postTeamUserMapper;
|
25
|
29
|
|
|
@@ -30,8 +34,7 @@ public class PostTeamUserServiceImpl extends ServiceImpl<PostTeamUserMapper, Pos
|
30
|
34
|
* @return 岗检小组关联成员
|
31
|
35
|
*/
|
32
|
36
|
@Override
|
33
|
|
- public PostTeamUser selectPostTeamUserById(Long id)
|
34
|
|
- {
|
|
37
|
+ public PostTeamUser selectPostTeamUserById(Long id) {
|
35
|
38
|
return postTeamUserMapper.selectPostTeamUserById(id);
|
36
|
39
|
}
|
37
|
40
|
|
|
@@ -42,40 +45,104 @@ public class PostTeamUserServiceImpl extends ServiceImpl<PostTeamUserMapper, Pos
|
42
|
45
|
* @return 岗检小组关联成员
|
43
|
46
|
*/
|
44
|
47
|
@Override
|
45
|
|
- public List<PostTeamUser> selectPostTeamUserList(PostTeamUser postTeamUser)
|
46
|
|
- {
|
|
48
|
+ public List<PostTeamUser> selectPostTeamUserList(PostTeamUser postTeamUser) {
|
47
|
49
|
return postTeamUserMapper.selectPostTeamUserList(postTeamUser);
|
48
|
50
|
}
|
49
|
51
|
|
50
|
52
|
/**
|
51
|
53
|
* 新增岗检小组关联成员
|
52
|
54
|
*
|
53
|
|
- * @param postTeamUser 岗检小组关联成员
|
|
55
|
+ * @param postTeamUserList 岗检小组关联成员数组
|
54
|
56
|
* @return 结果
|
55
|
57
|
*/
|
56
|
58
|
@Override
|
57
|
|
- public int insertPostTeamUser(PostTeamUser postTeamUser)
|
58
|
|
- {
|
59
|
|
- //TODO 自增主键修改为-MyBatis-Plus雪花算法(截取5位解决VUE精度丢失BUG)-系统登录日志
|
60
|
|
- if (postTeamUser.getId() == null)
|
|
59
|
+ public int insertPostTeamUser(List<PostTeamUser> postTeamUserList) {
|
|
60
|
+ if (CollectionUtils.isEmpty(postTeamUserList)) {
|
|
61
|
+ return 0;
|
|
62
|
+ }
|
|
63
|
+
|
|
64
|
+ List<Long> postTeamIdList = postTeamUserList.stream().map(t -> t.getPostTeamId()).collect(Collectors.toList());
|
|
65
|
+ if (CollectionUtils.isEmpty(postTeamIdList)) {
|
|
66
|
+ throw new BaseException("postTeamId为空,请检查!");
|
|
67
|
+ }
|
|
68
|
+
|
|
69
|
+ //删除原来的用户
|
|
70
|
+ LambdaQueryWrapper<PostTeamUser> wrapper = new LambdaQueryWrapper<>();
|
|
71
|
+ wrapper.in(PostTeamUser::getPostTeamId, postTeamIdList);
|
|
72
|
+ postTeamUserMapper.delete(wrapper);
|
|
73
|
+
|
|
74
|
+ //新增用户
|
|
75
|
+ int count = 0;
|
|
76
|
+ int index = 0;
|
|
77
|
+ for (PostTeamUser postTeamUser : postTeamUserList) {
|
|
78
|
+ //类型(1-组长;2-成员;)
|
|
79
|
+ if (index++ == 0) {
|
|
80
|
+ postTeamUser.setType(1);
|
|
81
|
+ } else {
|
|
82
|
+ postTeamUser.setType(2);
|
|
83
|
+ }
|
|
84
|
+ Long postTeamId = postTeamUser.getPostTeamId();
|
|
85
|
+ if (postTeamId == null) {
|
|
86
|
+ throw new BaseException("postTeamId为空,请检查!");
|
|
87
|
+ }
|
|
88
|
+
|
|
89
|
+ //TODO 自增主键修改为-MyBatis-Plus雪花算法(截取5位解决VUE精度丢失BUG)-系统登录日志
|
|
90
|
+// if (postTeamUser.getId() == null)
|
61
|
91
|
postTeamUser.setId(Long.parseLong(IdWorker.getIdStr().substring(4)));
|
62
|
|
- postTeamUser.setCreateDefault();
|
63
|
|
- return postTeamUserMapper.insertPostTeamUser(postTeamUser);
|
|
92
|
+ postTeamUser.setCreateDefault();
|
|
93
|
+ count += postTeamUserMapper.insertPostTeamUser(postTeamUser);
|
|
94
|
+ }
|
|
95
|
+ return count;
|
64
|
96
|
}
|
65
|
97
|
|
66
|
98
|
/**
|
67
|
99
|
* 修改岗检小组关联成员
|
68
|
100
|
*
|
69
|
|
- * @param postTeamUser 岗检小组关联成员
|
|
101
|
+ * @param postTeamUserList 岗检小组关联成员数组
|
70
|
102
|
* @return 结果
|
71
|
103
|
*/
|
72
|
|
- @Override
|
73
|
|
- public int updatePostTeamUser(PostTeamUser postTeamUser)
|
74
|
|
- {
|
75
|
|
- postTeamUser.setUpdateDefault();
|
76
|
|
- return postTeamUserMapper.updatePostTeamUser(postTeamUser);
|
77
|
|
- }
|
|
104
|
+ /* @Override
|
|
105
|
+ public int updatePostTeamUser(List<PostTeamUser> postTeamUserList) {
|
|
106
|
+ if (CollectionUtils.isEmpty(postTeamUserList)) {
|
|
107
|
+ return 0;
|
|
108
|
+ }
|
|
109
|
+
|
|
110
|
+ List<Long> postTeamIdList = postTeamUserList.stream().map(t -> t.getPostTeamId()).collect(Collectors.toList());
|
|
111
|
+ if (CollectionUtils.isEmpty(postTeamIdList)) {
|
|
112
|
+ throw new BaseException("postTeamId为空,请检查!");
|
|
113
|
+ }
|
|
114
|
+ //删除原来的用户
|
|
115
|
+ LambdaQueryWrapper<PostTeamUser> wrapper = new LambdaQueryWrapper<>();
|
|
116
|
+ wrapper.in(PostTeamUser::getPostTeamId, postTeamIdList);
|
|
117
|
+ postTeamUserMapper.delete(wrapper);
|
|
118
|
+
|
|
119
|
+ //新增用户
|
|
120
|
+ int count = 0;
|
|
121
|
+ int index = 0;
|
|
122
|
+ for (PostTeamUser postTeamUser : postTeamUserList) {
|
|
123
|
+ //类型(1-组长;2-成员;)
|
|
124
|
+ if (index++ == 0) {
|
|
125
|
+ postTeamUser.setType(1);
|
|
126
|
+ } else {
|
|
127
|
+ postTeamUser.setType(2);
|
|
128
|
+ }
|
78
|
129
|
|
|
130
|
+ Long postTeamId = postTeamUser.getPostTeamId();
|
|
131
|
+ if (postTeamId == null) {
|
|
132
|
+ throw new BaseException("postTeamId为空,请检查!");
|
|
133
|
+ }
|
|
134
|
+ //TODO 自增主键修改为-MyBatis-Plus雪花算法(截取5位解决VUE精度丢失BUG)-系统登录日志
|
|
135
|
+// if (postTeamUser.getId() == null)
|
|
136
|
+ postTeamUser.setId(Long.parseLong(IdWorker.getIdStr().substring(4)));
|
|
137
|
+ postTeamUser.setCreateDefault();
|
|
138
|
+ count += postTeamUserMapper.insertPostTeamUser(postTeamUser);
|
|
139
|
+ }
|
|
140
|
+ return count;
|
|
141
|
+
|
|
142
|
+// postTeamUser.setUpdateDefault();
|
|
143
|
+// return postTeamUserMapper.updatePostTeamUser(postTeamUser);
|
|
144
|
+ }
|
|
145
|
+*/
|
79
|
146
|
/**
|
80
|
147
|
* 批量删除岗检小组关联成员
|
81
|
148
|
*
|
|
@@ -83,8 +150,7 @@ public class PostTeamUserServiceImpl extends ServiceImpl<PostTeamUserMapper, Pos
|
83
|
150
|
* @return 结果
|
84
|
151
|
*/
|
85
|
152
|
@Override
|
86
|
|
- public int deletePostTeamUserByIds(Long[] ids)
|
87
|
|
- {
|
|
153
|
+ public int deletePostTeamUserByIds(Long[] ids) {
|
88
|
154
|
return postTeamUserMapper.deletePostTeamUserByIds(ids);
|
89
|
155
|
}
|
90
|
156
|
|
|
@@ -95,8 +161,7 @@ public class PostTeamUserServiceImpl extends ServiceImpl<PostTeamUserMapper, Pos
|
95
|
161
|
* @return 结果
|
96
|
162
|
*/
|
97
|
163
|
@Override
|
98
|
|
- public int deletePostTeamUserById(Long id)
|
99
|
|
- {
|
|
164
|
+ public int deletePostTeamUserById(Long id) {
|
100
|
165
|
return postTeamUserMapper.deletePostTeamUserById(id);
|
101
|
166
|
}
|
102
|
167
|
}
|