112 lines
4.9 KiB
C#
112 lines
4.9 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 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]
|
|
[HttpGet]
|
|
public async Task<BaseResponse<MyAccountInfoDto>> GetMyAccount()
|
|
{
|
|
var obj = JsonConvert.DeserializeObject<MyAccountInfoDto>("{\"Currency\":1,\"CurrencyRechargeList\":[{\"Id\":0,\"CurrencyCount\":100,\"Price\":10,\"Discount\":\" 0%\",\"CurrencyType\":0,\"ImgUrl\":\"\"},{\"Id\":1,\"CurrencyCount\":200,\"Price\":20,\"Discount\":\" -10%\",\"CurrencyType\":0,\"ImgUrl\":\"\"}]}");
|
|
return new BaseResponse<MyAccountInfoDto>(ResonseCode.Success, "", obj);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 我的 - 获取交易记录
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[AllowAnonymous]
|
|
[HttpGet]
|
|
public async Task<BaseResponse<List<TransactionDto>>> GetTransactionRecords()
|
|
{
|
|
var obj = JsonConvert.DeserializeObject<List<TransactionDto>>("[{\"TransactionContent\":\"购买记忆提升道具卡\",\"TransactionTime\":\"2024-07-18 12:58:52.963\",\"TransactionAmount\":\"-10\",\"TransactionType\":0,\"CurrencyType\":0},{\"TransactionContent\":\"充值语珠\",\"TransactionTime\":\"2024-07-17 12:58:52.963\",\"TransactionAmount\":\"+100\",\"TransactionType\":0,\"CurrencyType\":0},{\"TransactionContent\":\"充值语珠\",\"TransactionTime\":\"2024-07-16 12:58:52.963\",\"TransactionAmount\":\"+200\",\"TransactionType\":0,\"CurrencyType\":0}]");
|
|
return new BaseResponse<List<TransactionDto>>(ResonseCode.Success, "", obj);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 商城 - 获取商城商品
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
//[AllowAnonymous]
|
|
//[HttpGet]
|
|
//public async Task<BaseResponse<ShopInfoDto>> GetMallItem()
|
|
//{
|
|
// var obj = JsonConvert.DeserializeObject<ShopInfoDto>("{\"Mall\":[{\"PropId\":1,\"PropName\":\"记忆卡1\",\"PropCount\":100,\"PropType\":0,\"Price\":10,\"PriceType\":0,\"ImgUrl\":\"https://cos.shhuanmeng.com/image/20240718110512.png\"},{\"PropId\":2,\"PropName\":\"记忆卡2\",\"PropCount\":100,\"PropType\":0,\"Price\":20,\"PriceType\":0,\"ImgUrl\":\"https://cos.shhuanmeng.com/image/20240718110518.png\"}],\"Purchased\":[{\"PropId\":2,\"PropName\":\"记忆卡2\",\"PropCount\":100,\"PropType\":0,\"Price\":20,\"PriceType\":0,\"ImgUrl\":\"https://cos.shhuanmeng.com/image/20240718110518.png\",\"BuyingTime\":\"2024-07-09 03:33:09.563\"}]}");
|
|
// return new BaseResponse<ShopInfoDto>(ResonseCode.Success, "", obj);
|
|
//}
|
|
}
|
|
}
|