using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using GxPress.Service.Interface.VerificationCode; using System.Threading.Tasks; using GxPress.Auth; using GxPress.Request.App.VerificationCode; namespace GxPress.Api.AppControllers { /// /// 收藏上传验证码 /// [Route("api/app/verification-code")] [ApiController] [Authorize] public partial class VerificationCodeController : ControllerBase { private readonly IVerificationCodeService verificationCodeService; private readonly ILoginContext _loginContext; public VerificationCodeController(IVerificationCodeService verificationCodeService, ILoginContext loginContext) { this.verificationCodeService = verificationCodeService; _loginContext = loginContext; } /// /// 生成验证码 /// /// [HttpPost("send-code")] public async Task GetCodeAsync() { return await verificationCodeService.GetCodeAsync(_loginContext.AccountId); } /// /// 生成验证码 /// /// [HttpPost("app-send-code")] public async Task GetAppCodeAsync() { var code = await verificationCodeService.GetCodeAsync(_loginContext.AccountId); var result = new VerificationDto(); result.Code = code; var serviceUrl = GxPress.Common.Tools.ConfigHelper.GetValue("ServiceAddress:AddressUrlDownload"); result.ServiceUrl = $"{serviceUrl}/mobile/pcupload"; return result; } /// ///验证验证码码 /// /// [HttpPost("confirmation-code")] [AllowAnonymous] public async Task ConfirmationCodeAsync(VerificationCodeRequest request) { //request.UserId=_loginContext.AccountId; return await verificationCodeService.ConfirmationCodeAsync(request); } /// /// 持久连接验证码 /// /// [HttpPost("Lasting-confirmation-code")] [AllowAnonymous] public async Task LastingConfirmationCode(VerificationCodeRequest request) { return await verificationCodeService.LastingConfirmationCodeAsync(request); } } }