168 lines
5.3 KiB
C#
168 lines
5.3 KiB
C#
using Azure;
|
|
|
|
using HuanMeng.DotNetCore.Base;
|
|
using HuanMeng.DotNetCore.Utility;
|
|
using HuanMeng.DotNetCore.WeChat;
|
|
using HuanMeng.MiaoYu.Code.Mall;
|
|
using HuanMeng.MiaoYu.Code.Other;
|
|
using HuanMeng.MiaoYu.Code.Users;
|
|
using HuanMeng.MiaoYu.Model.Dto;
|
|
using HuanMeng.MiaoYu.Model.Dto.Account;
|
|
using HuanMeng.MiaoYu.Model.Dto.Shop;
|
|
using HuanMeng.MiaoYu.WebApi.Base;
|
|
|
|
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Http;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
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, ILogger<AccountController> logger) : base(_serviceProvider)
|
|
{
|
|
//logger.LogInformation("aaaaa");
|
|
}
|
|
|
|
/// <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();
|
|
}
|
|
/// <summary>
|
|
/// 解析微信用户数据
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[AllowAnonymous]
|
|
[HttpPost]
|
|
public async Task<string> GetMiniProgramUserInfo([FromBody] WXBizDataCryptModel wXBizDataCryptModel)
|
|
{
|
|
UserBLL userBLL = new UserBLL(ServiceProvider);
|
|
return await userBLL.GetMiniProgramUserInfo(wXBizDataCryptModel);
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 我的账户
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[HttpGet]
|
|
public async Task<BaseResponse<MyAccountInfoDto>> GetMyAccount()
|
|
{
|
|
ProductBLL productBLL = new ProductBLL(ServiceProvider);
|
|
return await productBLL.GetMyAccountInfoList();
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// 我的 - 获取交易记录
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[HttpGet]
|
|
public async Task<BaseResponse<List<TransactionDto>>> GetTransactionRecords()
|
|
{
|
|
UserBLL userBLL = new UserBLL(ServiceProvider);
|
|
return await userBLL.GetTransactionRecords();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 修改用户昵称
|
|
/// </summary>
|
|
/// <param name="requestAccountCommonUser"></param>
|
|
/// <returns></returns>
|
|
/// <exception cref="Exception"></exception>
|
|
[HttpPost]
|
|
public async Task<BaseResponse<bool>> UpdateUserNickName([FromBody] RequestAccountCommonUser requestAccountCommonUser)
|
|
{
|
|
UserBLL userBLL = new UserBLL(ServiceProvider);
|
|
return await userBLL.UpdateUserNickName(requestAccountCommonUser.NickName);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 修改用户头像
|
|
/// </summary>
|
|
/// <param name="requestAccountCommonUserImage"></param>
|
|
/// <returns></returns>
|
|
/// <exception cref="Exception"></exception>
|
|
[HttpPost]
|
|
public async Task<BaseResponse<bool>> UpdateUserIcon([FromBody] RequestAccountCommonUserImage requestAccountCommonUserImage)
|
|
{
|
|
UserBLL userBLL = new UserBLL(ServiceProvider);
|
|
return await userBLL.UpdateUserIcon(requestAccountCommonUserImage.UserIcon);
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 商城 - 获取商城商品 Mall
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[AllowAnonymous]
|
|
[HttpGet]
|
|
public async Task<BaseResponse<ShopInfoDto>> GetMallItem()
|
|
{
|
|
ProductBLL productBLL = new ProductBLL(ServiceProvider);
|
|
return await productBLL.GetShopInfoListAsync();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 注销账号
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[HttpPost]
|
|
[Authorize]
|
|
public async Task<BaseResponse<bool>> Logout()
|
|
{
|
|
UserBLL userBLL = new UserBLL(ServiceProvider);
|
|
return await userBLL.Logout();
|
|
}
|
|
}
|
|
}
|