using YBEE.EQM.Core;

namespace YBEE.EQM.Application;

/// <summary>
/// 用户登录认证服务
/// </summary>
[ApiDescriptionSettings(Name = "sys-auth")]
[Route("sys/auth")]
public class SysAuthAppService : IDynamicApiController
{
    private readonly ISysAuthService _authService;
    public SysAuthAppService(ISysAuthService authService)
    {
        _authService = authService;
    }

    /// <summary>
    /// 账户密码登录
    /// </summary>
    /// <param name="input"></param>
    /// <returns></returns>
    [AllowAnonymous]
    public async Task<AuthOutput> LoginByAccount(LoginInput input)
    {
        return await _authService.LoginByAccount(input);
    }

    /// <summary>
    /// 退出登录
    /// </summary>
    /// <returns></returns>
    [AllowAnonymous]
    public async Task Logout()
    {
        await _authService.Logout();
    }

    /// <summary>
    /// 获取当前登录用户信息
    /// </summary>
    /// <returns></returns>
    public async Task<LoginOutput> GetLoginUser()
    {
        return await _authService.GetLoginUser();
    }

    /// <summary>
    /// 获取图形验证码
    /// </summary>
    /// <returns></returns>
    [AllowAnonymous]
    [DisableOpLog]
    public async Task<GeneralCaptchaOutput> GetCaptcha()
    {
        return await _authService.GetCaptcha();
    }

    /// <summary>
    /// 校验图形验证码
    /// </summary>
    /// <param name="input"></param>
    /// <returns></returns>
    [AllowAnonymous]
    [DisableOpLog]
    public async Task<GeneralCaptchaOutput> VerifyCaptcha(GeneralCaptchaInput input)
    {
        return await _authService.VerifyCaptcha(input);
    }
}