feat(wechat): Add default template data builder for notification templates
All checks were successful
continuous-integration/drone/push Build is passing

- 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
This commit is contained in:
zpc 2026-03-29 21:39:20 +08:00
parent b1daa6c6c8
commit bcff4b759c

View File

@ -630,6 +630,22 @@ public class NotificationService : INotificationService
}
}
/// <summary>
/// 构建默认模板数据(兜底,数据库未配置字段映射时使用)
/// </summary>
private static Dictionary<string, TemplateDataItem> BuildDefaultTemplateData(
NotificationTemplateType templateType, string title, string name, string content, string time)
{
return new Dictionary<string, TemplateDataItem>
{
["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