StaffController.java
11.8 KB
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
package cn.com.glsx.merchants.controller;
import cn.com.glsx.framework.core.exception.RpcServiceException;
import cn.com.glsx.framework.rop.response.RopResponse;
import cn.com.glsx.merchants.request.staff.*;
import cn.com.glsx.merchants.response.StaffResponse;
import cn.com.glsx.merchants.service.StaffService;
import cn.com.glsx.merchants.util.Pagination;
import cn.com.glsx.merchants.util.PaginationDJ;
import com.rop.annotation.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/**
* @author zhouhaibao
* @version 1.0
* @description: TODO
* @date 2021/7/22 13:45
*/
@Slf4j
@Api("员工接口")
@ServiceMethodBean(version = "1.0.0", needInSession = NeedInSessionType.NO)
public class StaffController {
@Autowired
private StaffService staffService;
/**
* 保存员工
*
* @param staffSaveRequest 入参
* @return
*/
@ServiceMethod(method = "merchants.api.staff.saveStaff", needInSession = NeedInSessionType.NO)
@ApiOperation("保存员工")
public RopResponse<Boolean> saveStaff(StaffSaveRequest staffSaveRequest) {
try {
staffService.saveStaff(staffSaveRequest);
return RopResponse.success(true);
} catch (RpcServiceException e) {
log.info("=======StaffController__invoke__saveStaff__exception:{}", e.getMessage());
return RopResponse.error(e.getErrId(), e.getMessage());
}
}
/**
* 更新员工
*
* @param staffUpdateRequest 入参
* @return
*/
@ServiceMethod(method = "merchants.api.staff.updateStaff", needInSession = NeedInSessionType.NO)
@ApiOperation("更新员工")
public RopResponse<Boolean> updateStaff(StaffUpdateRequest staffUpdateRequest) {
try {
staffService.updateStaff(staffUpdateRequest);
return RopResponse.success(true);
} catch (RpcServiceException e) {
log.info("=======StaffController__invoke__updateStaff__exception:{}", e.getMessage());
return RopResponse.error(e.getErrId(), e.getMessage());
}
}
/**
* 更新员工状态
*
* @param staffUpdateStatusRequest 入参
* @return
*/
@ServiceMethod(method = "merchants.api.staff.updateStatus", needInSession = NeedInSessionType.NO)
@ApiOperation("更新员工状态")
public RopResponse<Boolean> updateStatus(StaffUpdateStatusRequest staffUpdateStatusRequest) {
try {
staffService.updateStatus(staffUpdateStatusRequest);
return RopResponse.success(true);
} catch (RpcServiceException e) {
log.info("=======StaffController__invoke__updateStaff__exception:{}", e.getMessage());
return RopResponse.error(e.getErrId(), e.getMessage());
}
}
/**
* 批量更新员工状态
*
* @param staffUpdateStatusBatchRequest 入参
* @return
*/
@ServiceMethod(method = "merchants.api.staff.updateStatusBatch", needInSession = NeedInSessionType.NO)
@ApiOperation("批量更新员工状态")
public RopResponse<Boolean> updateStatusBatch(StaffUpdateStatusBatchRequest staffUpdateStatusBatchRequest) {
try {
staffService.updateStatusBatch(staffUpdateStatusBatchRequest);
return RopResponse.success(true);
} catch (RpcServiceException e) {
log.info("=======StaffController__invoke__updateStatusBatch__exception:{}", e.getMessage());
return RopResponse.error(e.getErrId(), e.getMessage());
}
}
/**
* 批量分配员工角色
*
* @param staffRoleInsertBatchRequest 入参
* @return
*/
@ServiceMethod(method = "merchants.api.staff.addStaffRoleBatch", needInSession = NeedInSessionType.NO)
@ApiOperation("批量分配员工角色")
public RopResponse<Boolean> addStaffRoleBatch(StaffRoleInsertBatchRequest staffRoleInsertBatchRequest) {
try {
staffService.addRoleBatch(staffRoleInsertBatchRequest);
return RopResponse.success(true);
} catch (RpcServiceException e) {
log.info("=======StaffController__invoke__addStaffRoleBatch__exception:{}", e.getMessage());
return RopResponse.error(e.getErrId(), e.getMessage());
}
}
/**
* 删除员工
*
* @param staffDeleteRequest 入参
* @return
*/
@ServiceMethod(method = "merchants.api.staff.deleteStaff", needInSession = NeedInSessionType.NO)
@ApiOperation("删除员工")
public RopResponse<Boolean> deleteStaff(StaffDeleteRequest staffDeleteRequest) {
try {
staffService.deleteStaff(staffDeleteRequest);
return RopResponse.success(true);
} catch (RpcServiceException e) {
log.info("=======StaffController__invoke__deleteStaff__exception:{}", e.getMessage());
return RopResponse.error(e.getErrId(), e.getMessage());
}
}
/**
* 查询员工详情
*
* @param staffSearchRequest 入参
* @return
*/
@ServiceMethod(method = "merchants.api.staff.staffSearchRequest", needInSession = NeedInSessionType.NO)
@ApiOperation("查询员工详情")
public RopResponse<StaffResponse> findMerchantStaffDetail(StaffSearchRequest staffSearchRequest) {
try {
StaffResponse staffResponse = staffService.findMerchantStaffDetail(staffSearchRequest);
return RopResponse.success(staffResponse);
} catch (RpcServiceException e) {
log.info("=======StaffController__invoke__findMerchantStaffDetail__exception:{}", e.getMessage());
return RopResponse.error(e.getErrId(), e.getMessage());
}
}
/**
* 查询员工列表
*
* @param staffListRequest 入参
* @return
*/
@ServiceMethod(method = "merchants.api.staff.findMerchantStaffList", needInSession = NeedInSessionType.NO)
@ApiOperation("查询员工列表")
public RopResponse<List<StaffResponse>> findMerchantStaffList(StaffListRequest staffListRequest) {
try {
List<StaffResponse> staffResponse = staffService.findMerchantStaffList(staffListRequest);
return RopResponse.success(staffResponse);
} catch (RpcServiceException e) {
log.info("=======StaffController__invoke__findMerchantStaffList__exception:{}", e.getMessage());
return RopResponse.error(e.getErrId(), e.getMessage());
}
}
/**
* 查询员工分页列表
*
* @param staffPageRequest 入参
* @return
*/
@ServiceMethod(method = "merchants.api.staff.findStaffByPage", needInSession = NeedInSessionType.NO)
@ApiOperation("查询员工分页列表")
public RopResponse<Pagination<StaffResponse>> findStaffByPage(StaffPageRequest staffPageRequest) {
try {
Pagination<StaffResponse> list = staffService.findStaffByPage(staffPageRequest);
return RopResponse.success(list);
} catch (RpcServiceException e) {
log.info("=======MerchantMenuController__invoke__findStaffByPage__exception:{}", e.getMessage());
return RopResponse.error(e.getErrId(), e.getMessage());
}
}
/**
* 查询员工分页列表(智享后台-人员列表)
*
* @param staffPageRequest 入参
* @return
*/
@ServiceMethod(method = "merchants.api.staff.findStaffByPageForDJ", needInSession = NeedInSessionType.NO)
@ApiOperation("查询员工分页列表")
public RopResponse<PaginationDJ<StaffResponse>> findStaffByPageForDJ(StaffPageDJRequest staffPageRequest) {
try {
StaffPageRequest request = new StaffPageRequest();
BeanUtils.copyProperties(staffPageRequest,request);
request.setPageNum(staffPageRequest.getCurrentPage());
Pagination<StaffResponse> list = staffService.findStaffByPage(request);
PaginationDJ<StaffResponse> paginationDJ = new PaginationDJ<>();
paginationDJ.setPageSize(list.getPageSize());
paginationDJ.setPageNum(list.getPageNum());
paginationDJ.setTotal(list.getCount());
List<StaffResponse> resultList = list.getData();
if (CollectionUtils.isNotEmpty(resultList)){
resultList.forEach(v-> v.setLabelList(StringUtils.isNotEmpty(v.getStaffLabel()) ? Arrays.asList(v.getStaffLabel().split(",")) : new ArrayList<>()));
}
paginationDJ.setList(resultList);
return RopResponse.success(paginationDJ);
} catch (RpcServiceException e) {
log.info("=======MerchantMenuController__invoke__findStaffByPageForDJ__exception:{}", e.getMessage());
return RopResponse.error(e.getErrId(), e.getMessage());
}
}
/**
* 查询员工分页列表
*
* @param staffExportRequest 入参
* @return
*/
@ServiceMethod(method = "merchants.api.staff.exportData", needInSession = NeedInSessionType.NO)
@ApiOperation("员工导出")
public RopResponse<String> exportData(StaffExportRequest staffExportRequest) {
try {
String url = staffService.exportData(staffExportRequest);
return RopResponse.success(url);
} catch (RpcServiceException e) {
log.info("=======MerchantMenuController__invoke__exportData__exception:{}", e.getMessage());
return RopResponse.error(e.getErrId(), e.getMessage());
}
}
/**
* 更新员工的有效期
*
* @param staffUpdateValRequest 入参
* @return
*/
@ServiceMethod(method = "merchants.api.staff.updateValPerByStaffId", needInSession = NeedInSessionType.NO)
@ApiOperation("更新员工的有效期")
public RopResponse<Boolean> updateValPerByStaffId(StaffUpdateValRequest staffUpdateValRequest) {
try {
staffService.updateValPerByStaffId(staffUpdateValRequest);
return RopResponse.success(true);
} catch (RpcServiceException e) {
log.info("=======StaffController__invoke__updateValPerByStaffId__exception:{}", e.getMessage());
return RopResponse.error(e.getErrId(), e.getMessage());
}
}
@ServiceMethod(method = "merchants.api.staff.insertStaffBatchByPhone", needInSession = NeedInSessionType.NO)
@ApiOperation("批量新增售后专员和续保专员")
public RopResponse<Boolean> insertStaffBatchByPhone(StaffJsonRopRequest ropRequest) {
try {
staffService.insertStaffBatchByPhone(ropRequest.getMerchantNos());
return RopResponse.success(true);
} catch (RpcServiceException e) {
log.info("=======StaffController__invoke__insertStaffBatchByPhone__exception:{}", e.getMessage());
return RopResponse.error(e.getErrId(), e.getMessage());
}
}
@ServiceMethod(method = "merchants.api.staff.updateStaffBatch", needInSession = NeedInSessionType.NO)
@ApiOperation("批量更新员工")
public RopResponse<Boolean> updateStaffBatch(UpdateStaffBatchRequest request){
try {
staffService.updateStaffBatch(request);
return RopResponse.success(true);
} catch (RpcServiceException e) {
log.info("=======StaffController__invoke__updateStaffBatch__exception:{}", e.getMessage());
return RopResponse.error(e.getErrId(), e.getMessage());
}
}
}