平安校园
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.

RoleController.cs 5.0 KiB

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