feat(admin): 添加系统用户详情接口并优化用户删除逻辑
- 新增系统用户详情接口,通过 GET 请求获取用户信息 - 在用户删除接口中增加对超级管理员的保护,禁止删除 - 修正 ID 列表验证注解,使用 @NotNull 替代 @NotBlank
This commit is contained in:
parent
330cabdeb4
commit
b5fb8071cc
|
|
@ -34,9 +34,18 @@ public class SystemUserController {
|
|||
return Result.ok(iAdminService.pageList(pageRequest, query));
|
||||
}
|
||||
|
||||
@GetMapping("/user/detail")
|
||||
@ApiOperation("系统用户详情")
|
||||
public Result<AdminVO> getAdminUserDetail(@RequestParam Long id) {
|
||||
return Result.ok(BeanUtil.copyProperties(iAdminService.getById(id), AdminVO.class));
|
||||
}
|
||||
|
||||
@DeleteMapping("/user/delete")
|
||||
@ApiOperation("批量删除系统用户")
|
||||
public Result<?> deleteAdminUsers(@Validated @RequestBody IdListDTO idList) {
|
||||
if (idList.getIdList().contains(1)) {
|
||||
return Result.fail("存在超级管理员,禁止删除");
|
||||
}
|
||||
return Result.ok(iAdminService.removeByIds(idList.getIdList()));
|
||||
}
|
||||
@PostMapping("/user/add")
|
||||
|
|
|
|||
|
|
@ -2,12 +2,12 @@ package com.example.admin_server.model.dto;
|
|||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class IdListDTO {
|
||||
|
||||
@NotBlank(message = "ID列表不能为空")
|
||||
@NotNull(message = "ID列表不能为空")
|
||||
private List<Integer> idList;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue