平安校园
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

BizRoleController.cs 4.4 KiB

2 months ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. 
  2. //
  3. namespace SafeCampus.Web.Core;
  4. /// <summary>
  5. /// 业务角色管理控制器
  6. /// </summary>
  7. [ApiDescriptionSettings(Tag = "角色管理")]
  8. [Route("biz/organization/role")]
  9. [RolePermission]
  10. public class BizRoleController : IDynamicApiController
  11. {
  12. private readonly IResourceService _resourceService;
  13. private readonly IRoleService _roleService;
  14. private readonly ISysUserService _sysUserService;
  15. public BizRoleController(IResourceService resourceService, IRoleService roleService, ISysUserService sysUserService)
  16. {
  17. _resourceService = resourceService;
  18. _roleService = roleService;
  19. _sysUserService = sysUserService;
  20. }
  21. /// <summary>
  22. /// 角色分页查询
  23. /// </summary>
  24. /// <param name="input"></param>
  25. /// <returns></returns>
  26. [HttpGet("page")]
  27. [DisplayName("角色分页查询")]
  28. public async Task<dynamic> Page([FromQuery] RolePageInput input)
  29. {
  30. return await _roleService.Page(input);
  31. }
  32. /// <summary>
  33. /// 添加角色
  34. /// </summary>
  35. /// <param name="input"></param>
  36. /// <returns></returns>
  37. [HttpPost("add")]
  38. [DisplayName("添加角色")]
  39. public async Task Add([FromBody] RoleAddInput input)
  40. {
  41. await _roleService.Add(input);
  42. }
  43. /// <summary>
  44. /// 修改角色
  45. /// </summary>
  46. /// <param name="input"></param>
  47. /// <returns></returns>
  48. [HttpPost("edit")]
  49. [DisplayName("修改角色")]
  50. public async Task Edit([FromBody] RoleEditInput input)
  51. {
  52. await _roleService.Edit(input);
  53. }
  54. /// <summary>
  55. /// 删除角色
  56. /// </summary>
  57. /// <param name="input"></param>
  58. /// <returns></returns>
  59. [HttpPost("delete")]
  60. [DisplayName("删除角色")]
  61. public async Task Delete([FromBody] BaseIdListInput input)
  62. {
  63. await _roleService.Delete(input);
  64. }
  65. /// <summary>
  66. /// 获取角色授权资源树
  67. /// </summary>
  68. /// <returns></returns>
  69. [HttpGet("resourceTreeSelector")]
  70. [DisplayName("获取角色授权资源树")]
  71. public async Task<dynamic> ResourceTreeSelector()
  72. {
  73. return await _roleService.ResourceTreeSelector();
  74. }
  75. /// <summary>
  76. /// 获取角色拥有资源
  77. /// </summary>
  78. /// <param name="input"></param>
  79. /// <returns></returns>
  80. [HttpGet("ownResource")]
  81. [DisplayName("获取角色拥有资源")]
  82. public async Task<dynamic> OwnResource([FromQuery] BaseIdInput input)
  83. {
  84. return await _roleService.OwnResource(input, CateGoryConst.RELATION_SYS_ROLE_HAS_RESOURCE);
  85. }
  86. /// <summary>
  87. /// 给角色授权资源
  88. /// </summary>
  89. /// <param name="input"></param>
  90. /// <returns></returns>
  91. [HttpPost("grantResource")]
  92. [DisplayName("角色授权资源")]
  93. public async Task GrantResource([FromBody] GrantResourceInput input)
  94. {
  95. await _roleService.GrantResource(input);
  96. }
  97. /// <summary>
  98. /// 获取角色下的用户
  99. /// </summary>
  100. /// <param name="input"></param>
  101. /// <returns></returns>
  102. [HttpGet("ownUser")]
  103. [DisplayName("获取角色下的用户")]
  104. public async Task<dynamic> OwnUser([FromQuery] BaseIdInput input)
  105. {
  106. return await _roleService.OwnUser(input);
  107. }
  108. /// <summary>
  109. /// 给角色授权用户
  110. /// </summary>
  111. /// <param name="input"></param>
  112. /// <returns></returns>
  113. [HttpPost("grantUser")]
  114. [DisplayName("角色授权")]
  115. public async Task GrantUser([FromBody] GrantUserInput input)
  116. {
  117. await _roleService.GrantUser(input);
  118. }
  119. /// <summary>
  120. /// 获取角色树
  121. /// </summary>
  122. /// <returns></returns>
  123. [HttpGet("tree")]
  124. [DisplayName("获取角色树")]
  125. public async Task<dynamic> Tree([FromQuery] RoleTreeInput input)
  126. {
  127. return await _roleService.Tree(input);
  128. }
  129. /// <summary>
  130. /// 获取角色详情
  131. /// </summary>
  132. /// <param name="input"></param>
  133. /// <returns></returns>
  134. [HttpGet("detail")]
  135. [DisplayName("获取角色详情")]
  136. public async Task<dynamic> Detail([FromQuery] BaseIdInput input)
  137. {
  138. return await _roleService.Detail(input);
  139. }
  140. /// <summary>
  141. /// 获取角色选择器
  142. /// </summary>
  143. /// <returns></returns>
  144. [HttpGet("roleSelector")]
  145. [DisplayName("获取角色选择器")]
  146. public async Task<dynamic> RoleSelector([FromQuery] RoleSelectorInput input)
  147. {
  148. return await _roleService.RoleSelector(input);
  149. }
  150. }