1. 新增宠物皮肤初始枚举值、下拉列表接口及相关DTO 2. 完善商品实体与DTO,新增虚拟商品标记和类型ID字段 3. 重构用户认证体系,支持多用户切换并重新生成JWT令牌 4. 新增签到配置管理全套功能,包括增删改查和状态管理 5. 优化模型验证过滤器和基础响应类的命名规范 6. 新增补签功能,完善签到服务逻辑 7. 拆分用户详情DTO,新增各子数据分页查询接口 8. 重构微信控制器的用户ID获取逻辑,统一使用激活用户ID 9. 修复背包服务中补签卡的扣减逻辑 10. 新增家长姓名修改接口和相关服务实现
46 lines
1.5 KiB
C#
46 lines
1.5 KiB
C#
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.AspNetCore.Mvc.Filters;
|
|
using QYZH.InteractiveMagazine.Models.Dto;
|
|
|
|
|
|
namespace QYZH.InteractiveMagazine.Infrastructure.Middleware;
|
|
|
|
/// <summary>
|
|
/// 数据验证过滤器
|
|
/// </summary>
|
|
public class ModelValidActionFilterAttribute : ActionFilterAttribute
|
|
{
|
|
public override void OnActionExecuting(ActionExecutingContext context)
|
|
{
|
|
if (!context.ModelState.IsValid)
|
|
{
|
|
Dictionary<string, string> errorDic = new Dictionary<string, string>();
|
|
foreach (var key in context.ModelState.Keys)
|
|
{
|
|
var modelstate = context.ModelState[key];
|
|
if (modelstate.Errors.Any())
|
|
{
|
|
string errorStr = string.Join(",", modelstate.Errors.Select(e => e.ErrorMessage).ToList());
|
|
errorDic.Add(key, errorStr);
|
|
}
|
|
}
|
|
var result = new BaseResponse<Dictionary<string, string>>() { code = ResultCode.FAIL };
|
|
|
|
result.message = string.Join("|", errorDic.Select(e => e.Value).Distinct());
|
|
result.result = errorDic;
|
|
context.Result = new JsonResult(result);
|
|
}
|
|
}
|
|
|
|
//public override void OnActionExecuted(ActionExecutedContext context)
|
|
//{
|
|
// if (context.Exception != null)
|
|
// {
|
|
// BaseResponse result = new BaseResponse() { Code = ResultCode.Fail };
|
|
// result.Message = context.Exception.Message;
|
|
// context.Result = new JsonResult(result);
|
|
// }
|
|
//}
|
|
}
|
|
|