AuthController.cs 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. using System.Threading.Tasks;
  2. using Microsoft.AspNetCore.Mvc;
  3. using Microsoft.AspNetCore.Authorization;
  4. using Admin.Core.Attributes;
  5. using Admin.Core.Model.Output;
  6. using Admin.Core.Service.Admin.Auth;
  7. using Admin.Core.Service.Admin.Auth.Input;
  8. namespace Admin.Core.Controllers.Admin
  9. {
  10. /// <summary>
  11. /// 授权管理
  12. /// </summary>
  13. public class AuthController : AreaController
  14. {
  15. private readonly IAuthService _authServices;
  16. public AuthController(IAuthService authServices)
  17. {
  18. _authServices = authServices;
  19. }
  20. /// <summary>
  21. /// 获取验证码
  22. /// </summary>
  23. /// <param name="lastKey">上次验证码键</param>
  24. /// <returns></returns>
  25. [HttpGet]
  26. [AllowAnonymous]
  27. public async Task<IResponseOutput> GetVerifyCode(string lastKey)
  28. {
  29. return await _authServices.GetVerifyCodeAsync(lastKey);
  30. }
  31. /// <summary>
  32. /// 获取密钥
  33. /// </summary>
  34. /// <returns></returns>
  35. [HttpGet]
  36. [AllowAnonymous]
  37. public async Task<IResponseOutput> GetPassWordKey()
  38. {
  39. return await _authServices.GetPassWordKeyAsync();
  40. }
  41. /// <summary>
  42. /// 查询用户信息
  43. /// </summary>
  44. /// <returns></returns>
  45. [HttpGet]
  46. [Login]
  47. public async Task<IResponseOutput> GetUserInfo()
  48. {
  49. return await _authServices.GetUserInfoAsync();
  50. }
  51. /// <summary>
  52. /// 用户登录
  53. /// 根据登录信息生成Token
  54. /// </summary>
  55. /// <param name="input">登录信息</param>
  56. /// <returns></returns>
  57. [HttpPost]
  58. [AllowAnonymous]
  59. public async Task<IResponseOutput> Login(AuthLoginInput input)
  60. {
  61. return await _authServices.LoginAsync(input);
  62. }
  63. }
  64. }