// 大名科技(天津)有限公司版权所有 电话:18020030720 QQ:515096995
//
// 此源代码遵循位于源代码树根目录中的 LICENSE 文件的许可证
namespace Admin.NET.Plugin.GoView.Service;
///
/// 系统登录服务
///
[UnifyProvider("GoView")]
[ApiDescriptionSettings(GoViewConst.GroupName, Module = "goview", Name = "sys", Order = 500)]
public class GoViewSysService : IDynamicApiController
{
private readonly SysAuthService _sysAuthService;
private readonly SqlSugarRepository _sysUserRep;
private readonly SysCacheService _sysCacheService;
public GoViewSysService(SysAuthService sysAuthService,
SqlSugarRepository sysUserRep,
SysCacheService sysCacheService)
{
_sysAuthService = sysAuthService;
_sysUserRep = sysUserRep;
_sysCacheService = sysCacheService;
}
///
/// GoView 登录
///
///
[AllowAnonymous]
[DisplayName("GoView 登录")]
public async Task Login(GoViewLoginInput input)
{
_sysCacheService.Set(CommonConst.SysCaptcha, false);
var loginResult = await _sysAuthService.Login(new LoginInput()
{
Account = input.Username,
Password = input.Password,
});
_sysCacheService.Remove(CommonConst.SysCaptcha);
var sysUser = await _sysUserRep.AsQueryable().ClearFilter().FirstAsync(u => u.Account.Equals(input.Username));
return new GoViewLoginOutput()
{
Userinfo = new GoViewLoginUserInfo
{
Id = sysUser.Id.ToString(),
Username = sysUser.Account,
Nickname = sysUser.NickName,
},
Token = new GoViewLoginToken
{
TokenValue = $"Bearer {loginResult.AccessToken}"
}
};
}
///
/// GoView 退出
///
[DisplayName("GoView 退出")]
public void GetLogout()
{
_sysAuthService.Logout();
}
///
/// 获取 OSS 上传接口
///
///
[AllowAnonymous]
[ApiDescriptionSettings(Name = "GetOssInfo")]
[DisplayName("获取 OSS 上传接口")]
public Task GetOssInfo()
{
return Task.FromResult(new GoViewOssUrlOutput { BucketURL = "" });
}
}