75 lines
2.2 KiB
C#
75 lines
2.2 KiB
C#
using Azure;
|
|
|
|
using HuanMeng.DotNetCore.Base;
|
|
using HuanMeng.MiaoYu.Code.Other;
|
|
using HuanMeng.MiaoYu.Code.Users;
|
|
using HuanMeng.MiaoYu.Model.Dto;
|
|
using HuanMeng.MiaoYu.Model.Dto.Account;
|
|
using HuanMeng.MiaoYu.WebApi.Base;
|
|
using HuanMeng.Utility;
|
|
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Http;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
using System.Numerics;
|
|
using System.Text.RegularExpressions;
|
|
|
|
namespace HuanMeng.MiaoYu.WebApi.Controllers
|
|
{
|
|
/// <summary>
|
|
/// 账号控制器
|
|
/// </summary>
|
|
[Route("api/[controller]/[action]")]
|
|
[ApiController]
|
|
public class AccountController : MiaoYuControllerBase
|
|
{
|
|
public AccountController(IServiceProvider _serviceProvider) : base(_serviceProvider)
|
|
{
|
|
}
|
|
|
|
/// <summary>
|
|
/// 发送手机号验证码
|
|
/// </summary>
|
|
/// <param name="phone"></param>
|
|
/// <returns></returns>
|
|
/// <exception cref="ArgumentException"></exception>
|
|
[HttpPost]
|
|
public async Task<BaseResponse<bool>> SendPhoneNumber([FromBody] RequestPhoneNumberModel phone)
|
|
{
|
|
if (!PhoneNumberValidator.IsPhoneNumber(phone.PhoneNumber))
|
|
{
|
|
throw new ArgumentException("请输入正确的手机号");
|
|
}
|
|
UserBLL userBLL = new UserBLL(ServiceProvider);
|
|
return await userBLL.SendPhoneNumber(phone.PhoneNumber);
|
|
}
|
|
/// <summary>
|
|
/// 登录
|
|
/// </summary>
|
|
/// <param name="requestLoginModel"></param>
|
|
/// <returns></returns>
|
|
[HttpPost]
|
|
[AllowAnonymous]
|
|
public async Task<BaseResponse<ResponseAccountLogIn>> AccountLogIn([FromBody] RequestLoginModel requestLoginModel)
|
|
{
|
|
UserBLL userBLL = new UserBLL(ServiceProvider);
|
|
return await userBLL.AccountLogIn(requestLoginModel);
|
|
}
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[Authorize]
|
|
[HttpGet]
|
|
public async Task<BaseResponse<ResponseUserInfo>> GetUserInfo()
|
|
{
|
|
UserBLL userBLL = new UserBLL(ServiceProvider);
|
|
return await userBLL.GetUserInfo();
|
|
}
|
|
|
|
}
|
|
}
|