This commit is contained in:
parent
3764b6ef57
commit
b1daa6c6c8
|
|
@ -546,13 +546,13 @@ public class NotificationService : INotificationService
|
|||
|
||||
// 从数据库读取字段映射
|
||||
var fieldMapping = await GetServiceAccountFieldMappingAsync(templateType);
|
||||
_logger.LogInformation("服务号字段映射: TemplateType={TemplateType}, FieldMapping={FieldMapping}",
|
||||
templateType, fieldMapping != null ? System.Text.Json.JsonSerializer.Serialize(fieldMapping) : "null");
|
||||
Dictionary<string, TemplateDataItem> data;
|
||||
|
||||
if (fieldMapping != null && fieldMapping.Count > 0)
|
||||
{
|
||||
// 使用后台配置的字段映射动态构建
|
||||
// 映射格式: {"thing1":"title","thing2":"name","time3":"time","thing4":"content","thing5":"remark"}
|
||||
// 值映射: title->标题, name->名称, content->内容, time->时间, remark->备注
|
||||
data = new Dictionary<string, TemplateDataItem>();
|
||||
foreach (var (fieldName, valueKey) in fieldMapping)
|
||||
{
|
||||
|
|
@ -570,15 +570,8 @@ public class NotificationService : INotificationService
|
|||
}
|
||||
else
|
||||
{
|
||||
// 兜底:使用传统的 first/keyword 格式
|
||||
data = 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 = "点击查看详情" }
|
||||
};
|
||||
// 兜底:根据通知类型使用默认字段映射
|
||||
data = BuildDefaultTemplateData(templateType, title, name, content, time);
|
||||
}
|
||||
|
||||
var request = new ServiceAccountTemplateMessageRequest
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user