using LoginInput = Admin.NET.Plugin.GoView.Service.Dto.LoginInput; using LoginOutput = Admin.NET.Plugin.GoView.Service.Dto.LoginOutput; namespace Admin.NET.Plugin.GoView.Service; /// /// 系统登录服务 /// [UnifyProvider("GoView")] [ApiDescriptionSettings(GoViewConst.GroupName, Module = "goview", Name = "sys", Order = 500)] public class SystemService : IDynamicApiController { private readonly SysAuthService _sysAuthService; private readonly SqlSugarRepository _userRep; public SystemService(SysAuthService sysAuthService, SqlSugarRepository userRep) { _sysAuthService = sysAuthService; _userRep = userRep; } /// /// GoView 登录 /// /// [AllowAnonymous] [DisplayName("GoView 登录")] public async Task Login(LoginInput input) { var loginResult = await _sysAuthService.Login(new Core.Service.LoginInput() { Account = input.Username, Password = input.Password, }); var user = await _userRep.AsQueryable().Includes(t => t.SysOrg).Filter(null, true).FirstAsync(u => u.Account.Equals(input.Username)); return new LoginOutput() { UserInfo = new LoginUserInfo { Id = user.Id + "", Username = user.Account, Nickname = user.NickName, }, Token = new LoginToken { TokenValue = $"Bearer {loginResult.AccessToken}", } }; } /// /// GoView 退出 /// [HttpGet] [DisplayName("GoView 退出")] public void Logout() { _sysAuthService.Logout(); } /// /// 获取 OSS 上传接口 /// /// [AllowAnonymous] [ApiDescriptionSettings(Name = "GetOssInfo")] [DisplayName("获取 OSS 上传接口")] public Task GetOssInfo() { return Task.FromResult(new OssUrlOutput { BucketUrl = "" }); } }