GoViewSysService.cs 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. // 大名科技(天津)有限公司版权所有 电话:18020030720 QQ:515096995
  2. //
  3. // 此源代码遵循位于源代码树根目录中的 LICENSE 文件的许可证
  4. namespace Admin.NET.Plugin.GoView.Service;
  5. /// <summary>
  6. /// 系统登录服务
  7. /// </summary>
  8. [UnifyProvider("GoView")]
  9. [ApiDescriptionSettings(GoViewConst.GroupName, Module = "goview", Name = "sys", Order = 500)]
  10. public class GoViewSysService : IDynamicApiController
  11. {
  12. private readonly SysAuthService _sysAuthService;
  13. private readonly SqlSugarRepository<SysUser> _sysUserRep;
  14. private readonly SysCacheService _sysCacheService;
  15. public GoViewSysService(SysAuthService sysAuthService,
  16. SqlSugarRepository<SysUser> sysUserRep,
  17. SysCacheService sysCacheService)
  18. {
  19. _sysAuthService = sysAuthService;
  20. _sysUserRep = sysUserRep;
  21. _sysCacheService = sysCacheService;
  22. }
  23. /// <summary>
  24. /// GoView 登录
  25. /// </summary>
  26. /// <returns></returns>
  27. [AllowAnonymous]
  28. [DisplayName("GoView 登录")]
  29. public async Task<GoViewLoginOutput> Login(GoViewLoginInput input)
  30. {
  31. _sysCacheService.Set(CommonConst.SysCaptcha, false);
  32. var loginResult = await _sysAuthService.Login(new LoginInput()
  33. {
  34. Account = input.Username,
  35. Password = input.Password,
  36. });
  37. _sysCacheService.Remove(CommonConst.SysCaptcha);
  38. var sysUser = await _sysUserRep.AsQueryable().ClearFilter().FirstAsync(u => u.Account.Equals(input.Username));
  39. return new GoViewLoginOutput()
  40. {
  41. Userinfo = new GoViewLoginUserInfo
  42. {
  43. Id = sysUser.Id.ToString(),
  44. Username = sysUser.Account,
  45. Nickname = sysUser.NickName,
  46. },
  47. Token = new GoViewLoginToken
  48. {
  49. TokenValue = $"Bearer {loginResult.AccessToken}"
  50. }
  51. };
  52. }
  53. /// <summary>
  54. /// GoView 退出
  55. /// </summary>
  56. [DisplayName("GoView 退出")]
  57. public void GetLogout()
  58. {
  59. _sysAuthService.Logout();
  60. }
  61. /// <summary>
  62. /// 获取 OSS 上传接口
  63. /// </summary>
  64. /// <returns></returns>
  65. [AllowAnonymous]
  66. [ApiDescriptionSettings(Name = "GetOssInfo")]
  67. [DisplayName("获取 OSS 上传接口")]
  68. public Task<GoViewOssUrlOutput> GetOssInfo()
  69. {
  70. return Task.FromResult(new GoViewOssUrlOutput { BucketURL = "" });
  71. }
  72. }