using Microsoft.AspNetCore.Mvc.Filters; using System; using System.Collections.Generic; using System.Linq; using Microsoft.AspNetCore.Mvc; using System.Text; using System.Threading.Tasks; namespace ZR.Infrastructure.Helper; public static class LogMessageRegistry { public static readonly Dictionary> Templates = new Dictionary> { ["giftclaim:status"] = ctx => { if (ctx.HttpContext.Request.Query.TryGetValue("id", out var idStr) && ctx.HttpContext.Request.Query.TryGetValue("status", out var statusStr)) { var id = int.Parse(idStr); int status = int.Parse(statusStr); if (id > 0) { return $"礼品审核状态修改,礼品兑换ID:{id},修改时间:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")},修改状态为:{(status == 1 ? "通过" : "未通过")}"; } } return ""; } }; /// /// 获取日志消息模板 /// /// /// /// public static string GetMessage(string key, ResultExecutedContext client) { if (!Templates.TryGetValue(key, out var func)) { return ""; } return func(client); } }