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

288 lines
7.3 KiB

  1. //
  2. namespace SafeCampus.Web.Core;
  3. /// <summary>
  4. /// 用户管理控制器
  5. /// </summary>
  6. [ApiDescriptionSettings(Tag = "用户管理")]
  7. [Route("sys/organization/[controller]")]
  8. [SuperAdmin]
  9. public class UserController : BaseController
  10. {
  11. private readonly ISysUserService _sysUserService;
  12. private readonly ISysOrgService _sysOrgService;
  13. private readonly ISysPositionService _sysPositionService;
  14. private readonly ISysRoleService _sysRoleService;
  15. public UserController(ISysUserService sysUserService, ISysOrgService sysOrgService, ISysPositionService sysPositionService,
  16. ISysRoleService sysRoleService)
  17. {
  18. _sysUserService = sysUserService;
  19. _sysOrgService = sysOrgService;
  20. _sysPositionService = sysPositionService;
  21. _sysRoleService = sysRoleService;
  22. }
  23. #region Get请求
  24. /// <summary>
  25. /// 用户分页查询
  26. /// </summary>
  27. /// <param name="input"></param>
  28. /// <returns></returns>
  29. [HttpGet("page")]
  30. public async Task<dynamic> Page([FromQuery] UserPageInput input)
  31. {
  32. return await _sysUserService.Page(input);
  33. }
  34. /// <summary>
  35. /// 获取用户选择器
  36. /// </summary>
  37. /// <param name="input"></param>
  38. /// <returns></returns>
  39. [HttpGet("selector")]
  40. public async Task<dynamic> Selector([FromQuery] UserSelectorInput input)
  41. {
  42. return await _sysUserService.Selector(input);
  43. }
  44. /// <summary>
  45. /// 获取用户拥有角色
  46. /// </summary>
  47. /// <param name="input"></param>
  48. /// <returns></returns>
  49. [HttpGet("ownRole")]
  50. public async Task<dynamic> OwnRole([FromQuery] BaseIdInput input)
  51. {
  52. return await _sysUserService.OwnRole(input);
  53. }
  54. /// <summary>
  55. /// 获取用户拥有资源
  56. /// </summary>
  57. /// <param name="input"></param>
  58. /// <returns></returns>
  59. [HttpGet("ownResource")]
  60. public async Task<dynamic> OwnResource([FromQuery] BaseIdInput input)
  61. {
  62. return await _sysUserService.OwnResource(input);
  63. }
  64. /// <summary>
  65. /// 获取用户拥有权限
  66. /// </summary>
  67. /// <param name="input"></param>
  68. /// <returns></returns>
  69. [HttpGet("ownPermission")]
  70. public async Task<dynamic> OwnPermission([FromQuery] BaseIdInput input)
  71. {
  72. return await _sysUserService.OwnPermission(input);
  73. }
  74. /// <summary>
  75. /// 获取权限授权树
  76. /// </summary>
  77. /// <returns></returns>
  78. [HttpGet("permissionTreeSelector")]
  79. public async Task<dynamic> PermissionTreeSelector([FromQuery] BaseIdInput input)
  80. {
  81. return await _sysUserService.UserPermissionTreeSelector(input);
  82. }
  83. /// <summary>
  84. /// 导入预览
  85. /// </summary>
  86. /// <param name="input"></param>
  87. /// <returns></returns>
  88. [HttpPost("preview")]
  89. [DisableRequestSizeLimit]
  90. [SuppressMonitor]
  91. public async Task<dynamic> Preview([FromForm] ImportPreviewInput input)
  92. {
  93. return await _sysUserService.Preview(input);
  94. }
  95. /// <summary>
  96. /// 模板下载
  97. /// </summary>
  98. /// <returns></returns>
  99. [HttpGet(template: "template")]
  100. [SuppressMonitor]
  101. public async Task<dynamic> Template()
  102. {
  103. return await _sysUserService.Template();
  104. }
  105. /// <summary>
  106. /// 用户详情
  107. /// </summary>
  108. /// <param name="input"></param>
  109. /// <returns></returns>
  110. [HttpGet("detail")]
  111. [DisplayName("用户详情")]
  112. public async Task<dynamic> Detail([FromQuery] BaseIdInput input)
  113. {
  114. return await _sysUserService.Detail(input);
  115. }
  116. #endregion Get请求
  117. #region Post请求
  118. /// <summary>
  119. /// 添加用户
  120. /// </summary>
  121. /// <param name="input"></param>
  122. /// <returns></returns>
  123. [HttpPost("add")]
  124. [DisplayName("添加用户")]
  125. public async Task Add([FromBody] UserAddInput input)
  126. {
  127. await _sysUserService.Add(input);
  128. }
  129. /// <summary>
  130. /// 修改用户
  131. /// </summary>
  132. /// <param name="input"></param>
  133. /// <returns></returns>
  134. [HttpPost("edit")]
  135. [DisplayName("修改用户")]
  136. public async Task Edit([FromBody] UserEditInput input)
  137. {
  138. await _sysUserService.Edit(input);
  139. }
  140. /// <summary>
  141. /// 批量修改用户
  142. /// </summary>
  143. /// <param name="input"></param>
  144. /// <returns></returns>
  145. [HttpPost("edits")]
  146. [DisplayName("批量修改用户")]
  147. public async Task Edits([FromBody] BatchEditInput input)
  148. {
  149. await _sysUserService.Edits(input);
  150. }
  151. /// <summary>
  152. /// 删除用户
  153. /// </summary>
  154. /// <param name="input"></param>
  155. /// <returns></returns>
  156. [HttpPost("delete")]
  157. [DisplayName("删除用户")]
  158. public async Task Delete([FromBody] BaseIdListInput input)
  159. {
  160. await _sysUserService.Delete(input);
  161. }
  162. /// <summary>
  163. /// 禁用用户
  164. /// </summary>
  165. /// <param name="input"></param>
  166. /// <returns></returns>
  167. [HttpPost("disableUser")]
  168. [DisplayName("禁用用户")]
  169. public async Task DisableUser([FromBody] BaseIdInput input)
  170. {
  171. await _sysUserService.DisableUser(input);
  172. }
  173. /// <summary>
  174. /// 启用用户
  175. /// </summary>
  176. /// <param name="input"></param>
  177. /// <returns></returns>
  178. [HttpPost("enableUser")]
  179. [DisplayName("启用用户")]
  180. public async Task EnableUser([FromBody] BaseIdInput input)
  181. {
  182. await _sysUserService.EnableUser(input);
  183. }
  184. /// <summary>
  185. /// 重置密码
  186. /// </summary>
  187. /// <param name="input"></param>
  188. /// <returns></returns>
  189. [HttpPost("resetPassword")]
  190. [DisplayName("重置密码")]
  191. public async Task ResetPassword([FromBody] BaseIdInput input)
  192. {
  193. await _sysUserService.ResetPassword(input);
  194. }
  195. /// <summary>
  196. /// 给用户授权角色
  197. /// </summary>
  198. /// <param name="input"></param>
  199. /// <returns></returns>
  200. [HttpPost("grantRole")]
  201. [DisplayName("授权角色")]
  202. public async Task GrantRole([FromBody] UserGrantRoleInput input)
  203. {
  204. await _sysUserService.GrantRole(input);
  205. }
  206. /// <summary>
  207. /// 给用户授权资源
  208. /// </summary>
  209. /// <param name="input"></param>
  210. /// <returns></returns>
  211. [HttpPost("grantResource")]
  212. [DisplayName("用户授权资源")]
  213. public async Task GrantResource([FromBody] UserGrantResourceInput input)
  214. {
  215. await _sysUserService.GrantResource(input);
  216. }
  217. /// <summary>
  218. /// 给用户授权权限
  219. /// </summary>
  220. /// <param name="input"></param>
  221. /// <returns></returns>
  222. [HttpPost("grantPermission")]
  223. [DisplayName("用户授权权限")]
  224. public async Task GrantPermission([FromBody] GrantPermissionInput input)
  225. {
  226. await _sysUserService.GrantPermission(input);
  227. }
  228. /// <summary>
  229. /// 用户导入
  230. /// </summary>
  231. /// <param name="input"></param>
  232. /// <returns></returns>
  233. [HttpPost("import")]
  234. [DisplayName("用户导入")]
  235. public async Task<dynamic> Import([SuppressMonitor][FromBody] ImportResultInput<SysUserImportInput> input)
  236. {
  237. return await _sysUserService.Import(input);
  238. }
  239. /// <summary>
  240. /// 用户导出
  241. /// </summary>
  242. /// <param name="input"></param>
  243. /// <returns></returns>
  244. [HttpPost("export")]
  245. [DisplayName("用户导出")]
  246. public async Task<dynamic> Export([FromBody] UserPageInput input)
  247. {
  248. return await _sysUserService.Export(input);
  249. }
  250. #endregion Post请求
  251. }