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

174 lines
4.4 KiB

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