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

200 lines
5.0 KiB

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