1. 新增宠物皮肤初始枚举值、下拉列表接口及相关DTO 2. 完善商品实体与DTO,新增虚拟商品标记和类型ID字段 3. 重构用户认证体系,支持多用户切换并重新生成JWT令牌 4. 新增签到配置管理全套功能,包括增删改查和状态管理 5. 优化模型验证过滤器和基础响应类的命名规范 6. 新增补签功能,完善签到服务逻辑 7. 拆分用户详情DTO,新增各子数据分页查询接口 8. 重构微信控制器的用户ID获取逻辑,统一使用激活用户ID 9. 修复背包服务中补签卡的扣减逻辑 10. 新增家长姓名修改接口和相关服务实现
100 lines
3.3 KiB
C#
100 lines
3.3 KiB
C#
using Microsoft.AspNetCore.Mvc;
|
|
using QYZH.InteractiveMagazine.IService;
|
|
using QYZH.InteractiveMagazine.Models.Common;
|
|
using QYZH.InteractiveMagazine.Models.Dto;
|
|
|
|
namespace QYZH.InteractiveMagazine.WebApi.Controllers.WeChat;
|
|
|
|
/// <summary>
|
|
/// 小程序勋章控制器
|
|
/// </summary>
|
|
public class MedalController(IMedalService medalService, ILogger<MedalController> logger) : WeChatBaseController
|
|
{
|
|
/// <summary>
|
|
/// 获取所有勋章列表(含当前用户拥有状态)
|
|
/// </summary>
|
|
[HttpGet("all")]
|
|
public async Task<BaseResponse<List<WxMedalListOutput>>> GetAllMedals()
|
|
{
|
|
try
|
|
{
|
|
var userId = GetCurrentUserId();
|
|
if (userId == 0)
|
|
{
|
|
return BaseResponse<List<WxMedalListOutput>>.Fail(ResultCode.DENY, "未获取到用户信息");
|
|
}
|
|
|
|
var result = await medalService.GetAllMedalsAsync(userId);
|
|
return Success(result);
|
|
}
|
|
catch (BusinessException ex)
|
|
{
|
|
logger.LogWarning(ex, "获取勋章列表业务异常: {Message}", ex.Message);
|
|
return BaseResponse<List<WxMedalListOutput>>.Fail(ex.Message);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
logger.LogError(ex, "获取勋章列表系统异常");
|
|
return BaseResponse<List<WxMedalListOutput>>.Fail("获取勋章列表失败,请稍后重试");
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取用户已拥有的勋章列表
|
|
/// </summary>
|
|
[HttpGet("my")]
|
|
public async Task<BaseResponse<List<WxUserMedalOutput>>> GetUserMedals()
|
|
{
|
|
try
|
|
{
|
|
var userId = GetCurrentUserId();
|
|
if (userId == 0)
|
|
{
|
|
return BaseResponse<List<WxUserMedalOutput>>.Fail(ResultCode.DENY, "未获取到用户信息");
|
|
}
|
|
|
|
var result = await medalService.GetUserMedalsAsync(userId);
|
|
return Success(result);
|
|
}
|
|
catch (BusinessException ex)
|
|
{
|
|
logger.LogWarning(ex, "获取用户勋章列表业务异常: {Message}", ex.Message);
|
|
return BaseResponse<List<WxUserMedalOutput>>.Fail(ex.Message);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
logger.LogError(ex, "获取用户勋章列表系统异常");
|
|
return BaseResponse<List<WxUserMedalOutput>>.Fail("获取用户勋章列表失败,请稍后重试");
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 激活/获得勋章
|
|
/// </summary>
|
|
[HttpPost("activate")]
|
|
public async Task<BaseResponse<object>> ActivateMedal([FromBody] WxMedalActivateInput input)
|
|
{
|
|
try
|
|
{
|
|
var userId = GetCurrentUserId();
|
|
if (userId == 0)
|
|
{
|
|
return BaseResponse<object>.Fail(ResultCode.DENY, "未获取到用户信息");
|
|
}
|
|
|
|
await medalService.ActivateMedalAsync(userId, input);
|
|
return Success<object>(null!, "勋章激活成功");
|
|
}
|
|
catch (BusinessException ex)
|
|
{
|
|
logger.LogWarning(ex, "激活勋章业务异常: {Message}", ex.Message);
|
|
return BaseResponse<object>.Fail(ex.Message);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
logger.LogError(ex, "激活勋章系统异常,参数:{Input}", input);
|
|
return BaseResponse<object>.Fail("激活勋章失败,请稍后重试");
|
|
}
|
|
}
|
|
}
|