更新
This commit is contained in:
@ -47,10 +47,6 @@ public class UserController {
|
||||
}
|
||||
String password = user.getPassword();
|
||||
user.setPassword(BCrypt.hashpw(password, BCrypt.gensalt()));
|
||||
if (addUserDto.getRoleId() == null) {
|
||||
// 查询系统名字为默认角色的角色ID
|
||||
user.setRoleId(roleService.getOne(new LambdaQueryWrapper<Role>().eq(Role::getRoleName, "默认角色")).getId());
|
||||
}
|
||||
userService.save(user);
|
||||
return ApiResponse.success(null);
|
||||
}
|
||||
@ -91,16 +87,21 @@ public class UserController {
|
||||
public ApiResponse list(@Parameter(description = "分页数量") Integer pageNum,
|
||||
@Parameter(description = "分页大小") Integer pageSize,
|
||||
@Parameter(description = "搜索字段") String searchKey,
|
||||
@Parameter(description = "角色ID") String roleId) {
|
||||
@Parameter(description = "角色ID") String roleId,
|
||||
@Parameter(description = "用户状态") Integer status) {
|
||||
LambdaQueryWrapper<User> wrapper = new LambdaQueryWrapper<>();
|
||||
// 根据用户名或者昵称进行模糊搜索
|
||||
if (StringUtils.isNotBlank(searchKey)) {
|
||||
wrapper.like(User::getUsername, searchKey).or().like(User::getNickname, searchKey);
|
||||
wrapper.nested(q -> q.like(User::getUsername, searchKey).or().like(User::getNickname, searchKey));
|
||||
}
|
||||
// 根据角色ID等值搜索
|
||||
if (StringUtils.isNotBlank(roleId)) {
|
||||
wrapper.eq(User::getRoleId, roleId);
|
||||
}
|
||||
// 角色状态处理
|
||||
if (status != null) {
|
||||
wrapper.eq(User::getStatus, status);
|
||||
}
|
||||
Page<User> userPage = userService.page(new Page<>(pageNum, pageSize), wrapper);
|
||||
return ApiResponse.success(userPage);
|
||||
}
|
||||
@ -154,7 +155,7 @@ public class UserController {
|
||||
@Operation(summary = "删除用户")
|
||||
@PostMapping("/deletes")
|
||||
@RoleAccess(roleNames = "管理员")
|
||||
public ApiResponse deletes(@RequestBody List<String> ids) {
|
||||
public ApiResponse deletes(@Parameter(description = "用户ID列表") @RequestBody List<String> ids) {
|
||||
userService.removeByIds(ids);
|
||||
return ApiResponse.success(null);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user