GoViewSysService.cs 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. // 大名科技(天津)有限公司 版权所有
  2. //
  3. // 此源代码遵循位于源代码树根目录中的 LICENSE 文件的许可证
  4. //
  5. // 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动
  6. //
  7. // 任何基于本项目二次开发而产生的一切法律纠纷和责任,均与作者无关
  8. namespace Admin.NET.Plugin.GoView.Service;
  9. /// <summary>
  10. /// 系统登录服务
  11. /// </summary>
  12. [UnifyProvider("GoView")]
  13. [ApiDescriptionSettings(GoViewConst.GroupName, Module = "goview", Name = "sys", Order = 500)]
  14. public class GoViewSysService : IDynamicApiController
  15. {
  16. private readonly SysAuthService _sysAuthService;
  17. private readonly SqlSugarRepository<SysUser> _sysUserRep;
  18. private readonly SysCacheService _sysCacheService;
  19. public GoViewSysService(SysAuthService sysAuthService,
  20. SqlSugarRepository<SysUser> sysUserRep,
  21. SysCacheService sysCacheService)
  22. {
  23. _sysAuthService = sysAuthService;
  24. _sysUserRep = sysUserRep;
  25. _sysCacheService = sysCacheService;
  26. }
  27. /// <summary>
  28. /// GoView 登录
  29. /// </summary>
  30. /// <returns></returns>
  31. [AllowAnonymous]
  32. [DisplayName("GoView 登录")]
  33. public async Task<GoViewLoginOutput> Login(GoViewLoginInput input)
  34. {
  35. _sysCacheService.Set(CommonConst.SysCaptcha, false);
  36. var loginResult = await _sysAuthService.Login(new LoginInput()
  37. {
  38. Account = input.Username,
  39. Password = input.Password,
  40. });
  41. _sysCacheService.Remove(CommonConst.SysCaptcha);
  42. var sysUser = await _sysUserRep.AsQueryable().ClearFilter().FirstAsync(u => u.Account.Equals(input.Username));
  43. return new GoViewLoginOutput()
  44. {
  45. Userinfo = new GoViewLoginUserInfo
  46. {
  47. Id = sysUser.Id.ToString(),
  48. Username = sysUser.Account,
  49. Nickname = sysUser.NickName,
  50. },
  51. Token = new GoViewLoginToken
  52. {
  53. TokenValue = $"Bearer {loginResult.AccessToken}"
  54. }
  55. };
  56. }
  57. /// <summary>
  58. /// GoView 退出
  59. /// </summary>
  60. [DisplayName("GoView 退出")]
  61. public void GetLogout()
  62. {
  63. _sysAuthService.Logout();
  64. }
  65. /// <summary>
  66. /// 获取 OSS 上传接口
  67. /// </summary>
  68. /// <returns></returns>
  69. [AllowAnonymous]
  70. [ApiDescriptionSettings(Name = "GetOssInfo")]
  71. [DisplayName("获取 OSS 上传接口")]
  72. public Task<GoViewOssUrlOutput> GetOssInfo()
  73. {
  74. return Task.FromResult(new GoViewOssUrlOutput { BucketURL = "" });
  75. }
  76. }