2026-06-04 18:03:34 +08:00
|
|
|
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)
|
|
|
|
|
{
|
2026-06-10 17:53:38 +08:00
|
|
|
var userId = GetCurrentUserId();
|
|
|
|
|
if (userId == 0) return Fail("未获取到用户信息") as dynamic;
|
2026-06-04 18:03:34 +08:00
|
|
|
|
2026-06-10 17:53:38 +08:00
|
|
|
var items = await mallService.GetBagItemsAsync(userId, itemType);
|
2026-06-04 18:03:34 +08:00
|
|
|
return Success(items);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 使用背包物品(补签卡等消耗品)
|
|
|
|
|
/// </summary>
|
|
|
|
|
[HttpPost("useItem")]
|
|
|
|
|
public async Task<BaseResponse<UseItemOutput>> UseItem([FromBody] UseItemInput input)
|
|
|
|
|
{
|
2026-06-10 17:53:38 +08:00
|
|
|
var userId = GetCurrentUserId();
|
|
|
|
|
if (userId == 0) return Fail("未获取到用户信息") as dynamic;
|
2026-06-04 18:03:34 +08:00
|
|
|
|
2026-06-10 17:53:38 +08:00
|
|
|
var result = await mallService.UseItemAsync(userId, input);
|
2026-06-04 18:03:34 +08:00
|
|
|
return Success(result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 宠物换肤
|
|
|
|
|
/// </summary>
|
|
|
|
|
[HttpPost("equipSkin")]
|
|
|
|
|
public async Task<BaseResponse<object>> EquipSkin([FromBody] EquipSkinInput input)
|
|
|
|
|
{
|
2026-06-10 17:53:38 +08:00
|
|
|
var userId = GetCurrentUserId();
|
|
|
|
|
if (userId == 0) return Fail("未获取到用户信息") as dynamic;
|
2026-06-04 18:03:34 +08:00
|
|
|
|
2026-06-10 17:53:38 +08:00
|
|
|
await mallService.EquipSkinAsync(userId, input);
|
2026-06-04 18:03:34 +08:00
|
|
|
return Success<object>(null!, input.SkinId == 0 ? "已恢复默认皮肤" : "换肤成功");
|
|
|
|
|
}
|
|
|
|
|
}
|