SysUserController.java 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. package com.simuwang.manage.api.system;
  2. import com.simuwang.base.common.support.MybatisPage;
  3. import com.simuwang.base.common.support.vo.OnlyIdNameVO;
  4. import com.simuwang.base.pojo.dto.DeleteByIdCmd;
  5. import com.simuwang.base.pojo.dto.GetByIdQuery;
  6. import com.simuwang.base.pojo.dto.UpdateStatusCmd;
  7. import com.simuwang.base.pojo.dto.sys.*;
  8. import com.simuwang.base.pojo.vo.sys.SysRoleUserVO;
  9. import com.simuwang.base.pojo.vo.sys.SysUserVO;
  10. import com.simuwang.logging.SystemLog;
  11. import com.simuwang.manage.service.system.SysUserService;
  12. import jakarta.validation.Valid;
  13. import org.springframework.web.bind.annotation.*;
  14. import java.util.List;
  15. /**
  16. * 用户管理相关接口
  17. */
  18. @SystemLog(value = "用户管理")
  19. @RestController
  20. @RequestMapping("/v1/sys/user")
  21. public class SysUserController {
  22. private final SysUserService service;
  23. public SysUserController(SysUserService service) {
  24. this.service = service;
  25. }
  26. /**
  27. * 分页接口
  28. *
  29. * @param query 用户列表分页请求参数
  30. * @return /
  31. */
  32. @SystemLog(value = "分页搜索", saveResult = true)
  33. @GetMapping("page")
  34. public MybatisPage<SysUserVO> page(UserQuery query) {
  35. return this.service.findPage(query);
  36. }
  37. /**
  38. * 多表关联的分页接口(案例,此接口暂无使用场景)
  39. *
  40. * @param query 用户列表分页请求参数
  41. * @return /
  42. */
  43. @GetMapping("multi-join-page")
  44. public MybatisPage<SysRoleUserVO> multiJoinPage(RoleUserQuery query) {
  45. return this.service.findMultiPage(query);
  46. }
  47. /**
  48. * 新增用户
  49. *
  50. * @param command 用户信息
  51. */
  52. @SystemLog(value = "新增", type = SystemLog.Type.INSERT)
  53. @PostMapping("save")
  54. public boolean save(@Valid @RequestBody UserAddCmd command) {
  55. this.service.insert(command);
  56. return true;
  57. }
  58. /**
  59. * 更新用户
  60. *
  61. * @param command 用户id+用户信息
  62. */
  63. @SystemLog(value = "修改", type = SystemLog.Type.UPDATE)
  64. @PostMapping("update")
  65. public boolean update(@Valid @RequestBody UserEditCmd command) {
  66. this.service.update(command);
  67. return true;
  68. }
  69. /**
  70. * 更新用户状态接口
  71. *
  72. * @param command 用户id+状态对象
  73. */
  74. @SystemLog(value = "更新状态", type = SystemLog.Type.UPDATE)
  75. @PostMapping("update-status")
  76. public boolean updateStatus(@Valid @RequestBody UpdateStatusCmd command) {
  77. this.service.updateStatus(command);
  78. return true;
  79. }
  80. /**
  81. * 根据id删除用户信息接口
  82. *
  83. * @param command 用户id对象
  84. */
  85. @SystemLog(value = "删除", type = SystemLog.Type.DELETE)
  86. @PostMapping("del")
  87. public boolean deleteById(@Valid @RequestBody DeleteByIdCmd command) {
  88. this.service.delete(command);
  89. return true;
  90. }
  91. /**
  92. * 用户角色绑定
  93. *
  94. * @param command 用户绑定的角色对象
  95. */
  96. @SystemLog(value = "用户角色绑定", type = SystemLog.Type.UPDATE)
  97. @PostMapping("bind-roles")
  98. public boolean bindRoles(@Valid @RequestBody UserRoleBindCmd command) {
  99. this.service.bindRoles(command);
  100. return true;
  101. }
  102. /**
  103. * 获取用户绑定的角色
  104. *
  105. * @param query 用户id对象
  106. */
  107. @GetMapping("list-bind-roles")
  108. public List<OnlyIdNameVO> listBindRoles(@Valid @RequestBody GetByIdQuery query) {
  109. return this.service.getUserRoles(query);
  110. }
  111. }