1. 新增通用默认状态枚举 DefaultStatusEnum,替换原有分散的状态枚举 2. 重构用户体系:拆分 WxUser 独立表存储微信身份,Users 表改为角色子用户表并关联 WxUser 3. 重构勋章模块:新增系统/期刊勋章类型,调整 JournalId 为可空,新增勋章状态字段 4. 重构微信认证流程:基于 WxUser 生成 Token,支持多子用户管理 5. 清理冗余枚举文件,重构多处业务逻辑适配新的数据结构 6. 修复用户手机号关联逻辑,迁移手机号字段至 WxUser 表
53 lines
1.8 KiB
C#
53 lines
1.8 KiB
C#
using Microsoft.AspNetCore.Mvc;
|
|
using QYZH.InteractiveMagazine.IService;
|
|
using QYZH.InteractiveMagazine.Models.Dto;
|
|
using QYZH.InteractiveMagazine.Models.Dto.Bag;
|
|
|
|
namespace QYZH.InteractiveMagazine.WebApi.Controllers.WeChat;
|
|
|
|
/// <summary>
|
|
/// 小程序背包控制器
|
|
/// </summary>
|
|
public class BagController(IWxMallService mallService, ILogger<BagController> logger) : WeChatBaseController
|
|
{
|
|
/// <summary>
|
|
/// 获取背包物品列表
|
|
/// </summary>
|
|
/// <param name="itemType">物品类型筛选(可选): MakeUpCard, PetBg</param>
|
|
[HttpGet("items")]
|
|
public async Task<BaseResponse<List<UserBagOutput>>> GetBagItems([FromQuery] string? itemType = null)
|
|
{
|
|
var userId = GetCurrentWxUserId();
|
|
if (userId == null) return Fail("未获取到用户信息") as dynamic;
|
|
|
|
var items = await mallService.GetBagItemsAsync(userId.Value, itemType);
|
|
return Success(items);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 使用背包物品(补签卡等消耗品)
|
|
/// </summary>
|
|
[HttpPost("useItem")]
|
|
public async Task<BaseResponse<UseItemOutput>> UseItem([FromBody] UseItemInput input)
|
|
{
|
|
var userId = GetCurrentWxUserId();
|
|
if (userId == null) return Fail("未获取到用户信息") as dynamic;
|
|
|
|
var result = await mallService.UseItemAsync(userId.Value, input);
|
|
return Success(result);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 宠物换肤
|
|
/// </summary>
|
|
[HttpPost("equipSkin")]
|
|
public async Task<BaseResponse<object>> EquipSkin([FromBody] EquipSkinInput input)
|
|
{
|
|
var userId = GetCurrentWxUserId();
|
|
if (userId == null) return Fail("未获取到用户信息") as dynamic;
|
|
|
|
await mallService.EquipSkinAsync(userId.Value, input);
|
|
return Success<object>(null!, input.SkinId == 0 ? "已恢复默认皮肤" : "换肤成功");
|
|
}
|
|
}
|