1. 新增宠物皮肤初始枚举值、下拉列表接口及相关DTO 2. 完善商品实体与DTO,新增虚拟商品标记和类型ID字段 3. 重构用户认证体系,支持多用户切换并重新生成JWT令牌 4. 新增签到配置管理全套功能,包括增删改查和状态管理 5. 优化模型验证过滤器和基础响应类的命名规范 6. 新增补签功能,完善签到服务逻辑 7. 拆分用户详情DTO,新增各子数据分页查询接口 8. 重构微信控制器的用户ID获取逻辑,统一使用激活用户ID 9. 修复背包服务中补签卡的扣减逻辑 10. 新增家长姓名修改接口和相关服务实现
71 lines
2.4 KiB
C#
71 lines
2.4 KiB
C#
using Microsoft.AspNetCore.Mvc;
|
||
using QYZH.InteractiveMagazine.IService;
|
||
using QYZH.InteractiveMagazine.Models.Dto;
|
||
using QYZH.InteractiveMagazine.Models.Dto.Mall;
|
||
|
||
namespace QYZH.InteractiveMagazine.WebApi.Controllers.WeChat;
|
||
|
||
/// <summary>
|
||
/// 小程序商城控制器
|
||
/// </summary>
|
||
public class MallController(IWxMallService mallService, ILogger<MallController> logger) : WeChatBaseController
|
||
{
|
||
/// <summary>
|
||
/// 获取商城商品列表
|
||
/// </summary>
|
||
/// <param name="type">商品类型筛选(可选): MakeUpCard, PetBg</param>
|
||
[HttpGet("products")]
|
||
public async Task<BaseResponse<List<WxProductOutput>>> GetProducts([FromQuery] string? type = null)
|
||
{
|
||
var userId = GetCurrentUserId();
|
||
if (userId == 0) return Fail("未获取到用户信息") as dynamic;
|
||
|
||
var products = await mallService.GetProductsAsync(userId, type);
|
||
return Success(products);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 获取商品详情
|
||
/// </summary>
|
||
/// <param name="id">商品Id</param>
|
||
[HttpGet("product/{id}")]
|
||
public async Task<BaseResponse<WxProductOutput>> GetProductDetail(long id)
|
||
{
|
||
var userId = GetCurrentUserId();
|
||
if (userId == 0) return Fail("未获取到用户信息") as dynamic;
|
||
|
||
var product = await mallService.GetProductDetailAsync(userId, id);
|
||
if (product == null)
|
||
return BaseResponse<WxProductOutput>.Fail(ResultCode.DENY, "商品不存在或已下架");
|
||
|
||
return Success(product);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 积分兑换商品
|
||
/// </summary>
|
||
[HttpPost("exchange")]
|
||
public async Task<BaseResponse<ExchangeOutput>> Exchange([FromBody] ExchangeInput input)
|
||
{
|
||
var userId = GetCurrentUserId();
|
||
if (userId == 0) return Fail("未获取到用户信息") as dynamic;
|
||
|
||
var result = await mallService.ExchangeAsync(userId, input);
|
||
return Success(result);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 获取我的兑换记录
|
||
/// </summary>
|
||
/// <param name="limit">返回数量(默认20)</param>
|
||
[HttpGet("exchangeRecords")]
|
||
public async Task<BaseResponse<List<ExchangeRecordOutput>>> GetExchangeRecords([FromQuery] int limit = 20)
|
||
{
|
||
var userId = GetCurrentUserId();
|
||
if (userId == 0) return Fail("未获取到用户信息") as dynamic;
|
||
|
||
var records = await mallService.GetExchangeRecordsAsync(userId, limit);
|
||
return Success(records);
|
||
}
|
||
}
|