SystemService.cs 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. using LoginInput = Admin.NET.Plugin.GoView.Service.Dto.LoginInput;
  2. using LoginOutput = Admin.NET.Plugin.GoView.Service.Dto.LoginOutput;
  3. namespace Admin.NET.Plugin.GoView.Service;
  4. /// <summary>
  5. /// 系统登录服务
  6. /// </summary>
  7. [UnifyProvider("GoView")]
  8. [ApiDescriptionSettings(GoViewConst.GroupName, Module = "goview", Name = "sys", Order = 500)]
  9. public class SystemService : IDynamicApiController
  10. {
  11. private readonly SysAuthService _sysAuthService;
  12. private readonly SqlSugarRepository<SysUser> _userRep;
  13. public SystemService(SysAuthService sysAuthService, SqlSugarRepository<SysUser> userRep)
  14. {
  15. _sysAuthService = sysAuthService;
  16. _userRep = userRep;
  17. }
  18. /// <summary>
  19. /// GoView 登录
  20. /// </summary>
  21. /// <returns></returns>
  22. [AllowAnonymous]
  23. [DisplayName("GoView 登录")]
  24. public async Task<LoginOutput> Login(LoginInput input)
  25. {
  26. var loginResult = await _sysAuthService.Login(new Core.Service.LoginInput()
  27. {
  28. Account = input.Username,
  29. Password = input.Password,
  30. });
  31. var user = await _userRep.AsQueryable().Includes(t => t.SysOrg).Filter(null, true).FirstAsync(u => u.Account.Equals(input.Username));
  32. return new LoginOutput()
  33. {
  34. UserInfo = new LoginUserInfo
  35. {
  36. Id = user.Id + "",
  37. Username = user.Account,
  38. Nickname = user.NickName,
  39. },
  40. Token = new LoginToken
  41. {
  42. TokenValue = $"Bearer {loginResult.AccessToken}",
  43. }
  44. };
  45. }
  46. /// <summary>
  47. /// GoView 退出
  48. /// </summary>
  49. [HttpGet]
  50. [DisplayName("GoView 退出")]
  51. public void Logout()
  52. {
  53. _sysAuthService.Logout();
  54. }
  55. /// <summary>
  56. /// 获取 OSS 上传接口
  57. /// </summary>
  58. /// <returns></returns>
  59. [AllowAnonymous]
  60. [ApiDescriptionSettings(Name = "GetOssInfo")]
  61. [DisplayName("获取 OSS 上传接口")]
  62. public Task<OssUrlOutput> GetOssInfo()
  63. {
  64. return Task.FromResult(new OssUrlOutput { BucketUrl = "" });
  65. }
  66. }