|
|
@@ -46,6 +46,7 @@ public class UserController extends BaseController {
|
|
46
|
46
|
|
|
47
|
47
|
@Autowired
|
|
48
|
48
|
private IAddressBookService addressBookService;
|
|
|
49
|
+
|
|
49
|
50
|
@ApiOperation("列表")
|
|
50
|
51
|
@Log(title = "查询用户信息表列表", businessType = BusinessType.QUERY)
|
|
51
|
52
|
@GetMapping
|
|
|
@@ -54,21 +55,19 @@ public class UserController extends BaseController {
|
|
54
|
55
|
LambdaQueryWrapper<User> qw = new LambdaQueryWrapper();
|
|
55
|
56
|
|
|
56
|
57
|
qw.eq(input.getUserId() != null && input.getUserId() > 0, User::getUserId, input.getUserId());
|
|
57
|
|
- // qw.eq(input.getDeptId() != null && input.getDeptId() > 0, User::getDeptId, input.getDeptId());
|
|
58
|
|
- if (input.getDeptId() != null &&input.getDeptId()>0)
|
|
59
|
|
- {
|
|
|
58
|
+ // qw.eq(input.getDeptId() != null && input.getDeptId() > 0, User::getDeptId, input.getDeptId());
|
|
|
59
|
+ if (input.getDeptId() != null && input.getDeptId() > 0) {
|
|
60
|
60
|
//查询下级部门所有人员
|
|
61
|
|
- qw.and(wq->{
|
|
|
61
|
+ qw.and(wq -> {
|
|
62
|
62
|
wq.inSql(User::getDeptId, "select dept_id from sys_dept where " +
|
|
63
|
|
- " ancestors REGEXP CONCAT((select ancestors from sys_dept where dept_id="+input.getDeptId()+"),',',"
|
|
64
|
|
- +input.getDeptId()+") ") ;
|
|
65
|
|
- wq.or().eq(User::getDeptId,input.getDeptId());
|
|
|
63
|
+ " ancestors REGEXP CONCAT((select ancestors from sys_dept where dept_id=" + input.getDeptId() + "),',',"
|
|
|
64
|
+ + input.getDeptId() + ") ");
|
|
|
65
|
+ wq.or().eq(User::getDeptId, input.getDeptId());
|
|
66
|
66
|
});
|
|
67
|
67
|
}
|
|
68
|
68
|
//查询角色
|
|
69
|
|
- if (input.getRoleId()!=null&&input.getRoleId()>0)
|
|
70
|
|
- {
|
|
71
|
|
- qw.inSql(User::getUserId, "select user_id from sys_user_role where role_id="+input.getRoleId());
|
|
|
69
|
+ if (input.getRoleId() != null && input.getRoleId() > 0) {
|
|
|
70
|
+ qw.inSql(User::getUserId, "select user_id from sys_user_role where role_id=" + input.getRoleId());
|
|
72
|
71
|
}
|
|
73
|
72
|
qw.like(!StringHelper.isEmpty(input.getUserName()), User::getUserName, input.getUserName());
|
|
74
|
73
|
qw.like(!StringHelper.isEmpty(input.getNickName()), User::getNickName, input.getNickName());
|
|
|
@@ -86,7 +85,6 @@ public class UserController extends BaseController {
|
|
86
|
85
|
IPage<User> iPage = userService.selectUserDeptList(page, qw);
|
|
87
|
86
|
|
|
88
|
87
|
|
|
89
|
|
-
|
|
90
|
88
|
return Success("成功", iPage.getRecords(), iPage.getTotal());
|
|
91
|
89
|
} else {
|
|
92
|
90
|
return Success("成功", userService.selectUserDeptList(qw));
|
|
|
@@ -131,17 +129,15 @@ public class UserController extends BaseController {
|
|
131
|
129
|
if (result) {
|
|
132
|
130
|
|
|
133
|
131
|
//根据电话,判断通讯录中是否存在,不存在新增一条记录
|
|
134
|
|
- LambdaQueryWrapper<AddressBook> lqwaddress=new LambdaQueryWrapper<>();
|
|
135
|
|
- lqwaddress.eq(AddressBook::getMobile,user.getPhonenumber());
|
|
|
132
|
+ LambdaQueryWrapper<AddressBook> lqwaddress = new LambdaQueryWrapper<>();
|
|
|
133
|
+ lqwaddress.eq(AddressBook::getMobile, user.getPhonenumber());
|
|
136
|
134
|
|
|
137
|
|
- List<AddressBook> addressBooks= addressBookService.getList(lqwaddress);
|
|
|
135
|
+ List<AddressBook> addressBooks = addressBookService.getList(lqwaddress);
|
|
138
|
136
|
|
|
139
|
|
- if(addressBooks!=null &&addressBooks.stream().count()>0)
|
|
140
|
|
- {
|
|
|
137
|
+ if (addressBooks != null && addressBooks.stream().count() > 0) {
|
|
141
|
138
|
|
|
142
|
|
- }
|
|
143
|
|
- else {
|
|
144
|
|
- AddressBook addressBook=new AddressBook();
|
|
|
139
|
+ } else {
|
|
|
140
|
+ AddressBook addressBook = new AddressBook();
|
|
145
|
141
|
addressBook.setMobile(user.getPhonenumber());
|
|
146
|
142
|
addressBook.setName(user.getNickName());
|
|
147
|
143
|
addressBook.setType(2L);
|
|
|
@@ -172,7 +168,7 @@ public class UserController extends BaseController {
|
|
172
|
168
|
return Error("修改用户'" + user.getUserName() + "'失败,邮箱账号已存在");
|
|
173
|
169
|
}
|
|
174
|
170
|
User use = userService.selectUserById(user.getUserId());
|
|
175
|
|
- if (use==null)
|
|
|
171
|
+ if (use == null)
|
|
176
|
172
|
return Error("用户不存在");
|
|
177
|
173
|
user.setPassword(use.getPassword());
|
|
178
|
174
|
user.setCreateBy(CurrentUser().getUserName());
|
|
|
@@ -180,20 +176,18 @@ public class UserController extends BaseController {
|
|
180
|
176
|
boolean result = userService.update(user);
|
|
181
|
177
|
if (result) {
|
|
182
|
178
|
//根据电话,判断通讯录中是否存在,不存在新增一条记录
|
|
183
|
|
- LambdaQueryWrapper<AddressBook> lqwaddress=new LambdaQueryWrapper<>();
|
|
184
|
|
- lqwaddress.eq(AddressBook::getMobile,user.getPhonenumber());
|
|
|
179
|
+ LambdaQueryWrapper<AddressBook> lqwaddress = new LambdaQueryWrapper<>();
|
|
|
180
|
+ lqwaddress.eq(AddressBook::getMobile, user.getPhonenumber());
|
|
185
|
181
|
|
|
186
|
|
- List<AddressBook> addressBooks= addressBookService.getList(lqwaddress);
|
|
|
182
|
+ List<AddressBook> addressBooks = addressBookService.getList(lqwaddress);
|
|
187
|
183
|
|
|
188
|
|
- if(addressBooks!=null &&addressBooks.stream().count()>0)
|
|
189
|
|
- {
|
|
190
|
|
- AddressBook addr= addressBooks.stream().findFirst().get();
|
|
|
184
|
+ if (addressBooks != null && addressBooks.stream().count() > 0) {
|
|
|
185
|
+ AddressBook addr = addressBooks.stream().findFirst().get();
|
|
191
|
186
|
addr.setName(user.getNickName());
|
|
192
|
187
|
addressBookService.update(addr);
|
|
193
|
188
|
|
|
194
|
|
- }
|
|
195
|
|
- else {
|
|
196
|
|
- AddressBook addressBook=new AddressBook();
|
|
|
189
|
+ } else {
|
|
|
190
|
+ AddressBook addressBook = new AddressBook();
|
|
197
|
191
|
addressBook.setMobile(user.getPhonenumber());
|
|
198
|
192
|
addressBook.setName(user.getNickName());
|
|
199
|
193
|
addressBook.setType(2L);
|
|
|
@@ -238,7 +232,7 @@ public class UserController extends BaseController {
|
|
238
|
232
|
public AjaxResult resetPwd(@RequestBody User user) {
|
|
239
|
233
|
//校验用户操作
|
|
240
|
234
|
//校验用户权限
|
|
241
|
|
- // userService.checkUserAllowed(user);
|
|
|
235
|
+ // userService.checkUserAllowed(user);
|
|
242
|
236
|
//userService.checkUserDataScope(user);
|
|
243
|
237
|
|
|
244
|
238
|
LambdaQueryWrapper<User> qw = new LambdaQueryWrapper<>();
|
|
|
@@ -260,19 +254,19 @@ public class UserController extends BaseController {
|
|
260
|
254
|
}
|
|
261
|
255
|
return Error("修改失败!");
|
|
262
|
256
|
}
|
|
|
257
|
+
|
|
263
|
258
|
/**
|
|
264
|
259
|
* 修改密码
|
|
265
|
260
|
*/
|
|
266
|
261
|
@ApiOperation("修改密码")
|
|
267
|
262
|
@Log(title = "修改密码", businessType = BusinessType.OTHER)
|
|
268
|
263
|
@PutMapping("/UpdatePwd")
|
|
269
|
|
- public AjaxResult UpdatePwd(String oldPwd ,String Pwd) {
|
|
270
|
|
- UserView currentUser=CurrentUser();
|
|
271
|
|
- if (!currentUser.getPassword().equals(SecretHelper.MD5(oldPwd)))
|
|
272
|
|
- {
|
|
|
264
|
+ public AjaxResult UpdatePwd(String oldPwd, String Pwd) {
|
|
|
265
|
+ UserView currentUser = CurrentUser();
|
|
|
266
|
+ if (!currentUser.getPassword().equals(SecretHelper.MD5(oldPwd))) {
|
|
273
|
267
|
return Error("旧密码不正确");
|
|
274
|
268
|
}
|
|
275
|
|
- var entity=userService.getEntity(currentUser.getUserId());
|
|
|
269
|
+ var entity = userService.getEntity(currentUser.getUserId());
|
|
276
|
270
|
String password = SecretHelper.MD5(Pwd);
|
|
277
|
271
|
entity.setPassword(password);
|
|
278
|
272
|
if (userService.update(entity)) {
|
|
|
@@ -287,15 +281,16 @@ public class UserController extends BaseController {
|
|
287
|
281
|
@ApiOperation("修改图像")
|
|
288
|
282
|
@Log(title = "修改图像", businessType = BusinessType.OTHER)
|
|
289
|
283
|
@GetMapping("/avatar")
|
|
290
|
|
- public AjaxResult avatar( String url) {
|
|
291
|
|
- UserView currentUser=CurrentUser();
|
|
292
|
|
- var entity=userService.getEntity(currentUser.getUserId());
|
|
|
284
|
+ public AjaxResult avatar(String url) {
|
|
|
285
|
+ UserView currentUser = CurrentUser();
|
|
|
286
|
+ var entity = userService.getEntity(currentUser.getUserId());
|
|
293
|
287
|
entity.setAvatar(url);
|
|
294
|
288
|
if (userService.update(entity)) {
|
|
295
|
289
|
return Success("修改成功!");
|
|
296
|
290
|
}
|
|
297
|
291
|
return Error("修改失败!");
|
|
298
|
292
|
}
|
|
|
293
|
+
|
|
299
|
294
|
/**
|
|
300
|
295
|
* 修改状态
|
|
301
|
296
|
*
|
|
|
@@ -335,7 +330,6 @@ public class UserController extends BaseController {
|
|
335
|
330
|
}
|
|
336
|
331
|
|
|
337
|
332
|
|
|
338
|
|
-
|
|
339
|
333
|
@GetMapping("/deptUserTree")
|
|
340
|
334
|
@Anonymous
|
|
341
|
335
|
public AjaxResult deptUserTree(Dept dept) {
|
|
|
@@ -343,11 +337,8 @@ public class UserController extends BaseController {
|
|
343
|
337
|
}
|
|
344
|
338
|
|
|
345
|
339
|
|
|
346
|
|
-
|
|
347
|
|
-
|
|
348
|
340
|
/**
|
|
349
|
341
|
* 导出excel
|
|
350
|
|
- *
|
|
351
|
342
|
*/
|
|
352
|
343
|
@ApiOperation("导出Excel")
|
|
353
|
344
|
@Log(title = "导出excel", businessType = BusinessType.EXPORT)
|
|
|
@@ -444,6 +435,7 @@ public class UserController extends BaseController {
|
|
444
|
435
|
|
|
445
|
436
|
/**
|
|
446
|
437
|
* 分配角色
|
|
|
438
|
+ *
|
|
447
|
439
|
* @param userId
|
|
448
|
440
|
* @return
|
|
449
|
441
|
*/
|