From bcff4b759c45ae93a015f7c6c73ed1f6fde233a8 Mon Sep 17 00:00:00 2001 From: zpc Date: Sun, 29 Mar 2026 21:39:20 +0800 Subject: [PATCH] feat(wechat): Add default template data builder for notification templates - Add BuildDefaultTemplateData method to construct fallback template data - Map notification fields to WeChat template placeholders (first, keyword1-3, remark) - Provide default template structure when database field mapping is not configured - Ensures template messages can be sent with sensible defaults as safety net --- .../Services/NotificationService.cs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/server/src/XiangYi.Application/Services/NotificationService.cs b/server/src/XiangYi.Application/Services/NotificationService.cs index 5a6755e..add63b1 100644 --- a/server/src/XiangYi.Application/Services/NotificationService.cs +++ b/server/src/XiangYi.Application/Services/NotificationService.cs @@ -630,6 +630,22 @@ public class NotificationService : INotificationService } } + /// + /// 构建默认模板数据(兜底,数据库未配置字段映射时使用) + /// + private static Dictionary BuildDefaultTemplateData( + NotificationTemplateType templateType, string title, string name, string content, string time) + { + return new Dictionary + { + ["first"] = new TemplateDataItem { Value = title }, + ["keyword1"] = new TemplateDataItem { Value = name }, + ["keyword2"] = new TemplateDataItem { Value = content }, + ["keyword3"] = new TemplateDataItem { Value = time }, + ["remark"] = new TemplateDataItem { Value = "点击查看详情" } + }; + } + #endregion