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

UserController.cs 7.3 KiB

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