This commit is contained in:
parent
55d36ffd8e
commit
e9bdf2623a
|
|
@ -193,12 +193,16 @@ export interface NotificationTemplatesConfig {
|
|||
encodingAESKey?: string
|
||||
unlockTemplateId?: string
|
||||
unlockFieldMapping?: string
|
||||
unlockPage?: string
|
||||
favoriteTemplateId?: string
|
||||
favoriteFieldMapping?: string
|
||||
favoritePage?: string
|
||||
messageTemplateId?: string
|
||||
messageFieldMapping?: string
|
||||
messagePage?: string
|
||||
dailyRecommendTemplateId?: string
|
||||
dailyRecommendFieldMapping?: string
|
||||
dailyRecommendPage?: string
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -346,7 +346,17 @@
|
|||
placeholder='例: {"thing1":"title","thing2":"name","time3":"time"}'
|
||||
clearable
|
||||
/>
|
||||
<div class="template-tip">JSON格式,key为模板字段名,value为数据类型:title=标题, name=名称, content=内容, time=时间, remark=备注</div>
|
||||
<div class="template-tip">JSON格式,key为模板字段名,value为数据类型:title=标题, name=名称, content=内容, time=时间, phone=手机号, remark=备注</div>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="解锁通知跳转页面">
|
||||
<el-select v-model="templateForm.unlockPage" placeholder="默认: pages/interact/unlockedMe" clearable style="width: 100%;">
|
||||
<el-option label="解锁我 (pages/interact/unlockedMe)" value="pages/interact/unlockedMe" />
|
||||
<el-option label="收藏我 (pages/interact/favoritedMe)" value="pages/interact/favoritedMe" />
|
||||
<el-option label="看过我 (pages/interact/viewedMe)" value="pages/interact/viewedMe" />
|
||||
<el-option label="聊天 (pages/chat/index)" value="pages/chat/index" />
|
||||
<el-option label="首页 (pages/index/index)" value="pages/index/index" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="收藏通知模板ID">
|
||||
|
|
@ -364,7 +374,17 @@
|
|||
placeholder='例: {"thing1":"title","thing2":"name","time3":"time"}'
|
||||
clearable
|
||||
/>
|
||||
<div class="template-tip">JSON格式,key为模板字段名,value为数据类型:title=标题, name=名称, content=内容, time=时间, remark=备注</div>
|
||||
<div class="template-tip">JSON格式,key为模板字段名,value为数据类型:title=标题, name=名称, content=内容, time=时间, phone=手机号, remark=备注</div>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="收藏通知跳转页面">
|
||||
<el-select v-model="templateForm.favoritePage" placeholder="默认: pages/interact/favoritedMe" clearable style="width: 100%;">
|
||||
<el-option label="收藏我 (pages/interact/favoritedMe)" value="pages/interact/favoritedMe" />
|
||||
<el-option label="解锁我 (pages/interact/unlockedMe)" value="pages/interact/unlockedMe" />
|
||||
<el-option label="看过我 (pages/interact/viewedMe)" value="pages/interact/viewedMe" />
|
||||
<el-option label="聊天 (pages/chat/index)" value="pages/chat/index" />
|
||||
<el-option label="首页 (pages/index/index)" value="pages/index/index" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="消息通知模板ID">
|
||||
|
|
@ -382,7 +402,17 @@
|
|||
placeholder='例: {"thing1":"title","thing2":"name","time3":"time"}'
|
||||
clearable
|
||||
/>
|
||||
<div class="template-tip">JSON格式,key为模板字段名,value为数据类型:title=标题, name=名称, content=内容, time=时间, remark=备注</div>
|
||||
<div class="template-tip">JSON格式,key为模板字段名,value为数据类型:title=标题, name=名称, content=内容, time=时间, phone=手机号, remark=备注</div>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="消息通知跳转页面">
|
||||
<el-select v-model="templateForm.messagePage" placeholder="默认: pages/chat/index" clearable style="width: 100%;">
|
||||
<el-option label="聊天 (pages/chat/index)" value="pages/chat/index" />
|
||||
<el-option label="收藏我 (pages/interact/favoritedMe)" value="pages/interact/favoritedMe" />
|
||||
<el-option label="解锁我 (pages/interact/unlockedMe)" value="pages/interact/unlockedMe" />
|
||||
<el-option label="看过我 (pages/interact/viewedMe)" value="pages/interact/viewedMe" />
|
||||
<el-option label="首页 (pages/index/index)" value="pages/index/index" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="每日推荐通知模板ID">
|
||||
|
|
@ -400,7 +430,17 @@
|
|||
placeholder='例: {"thing1":"title","thing2":"content","time3":"time"}'
|
||||
clearable
|
||||
/>
|
||||
<div class="template-tip">JSON格式,key为模板字段名,value为数据类型:title=标题, name=名称, content=内容, time=时间, remark=备注</div>
|
||||
<div class="template-tip">JSON格式,key为模板字段名,value为数据类型:title=标题, name=名称, content=内容, time=时间, phone=手机号, remark=备注</div>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="每日推荐跳转页面">
|
||||
<el-select v-model="templateForm.dailyRecommendPage" placeholder="默认: pages/index/index" clearable style="width: 100%;">
|
||||
<el-option label="首页 (pages/index/index)" value="pages/index/index" />
|
||||
<el-option label="收藏我 (pages/interact/favoritedMe)" value="pages/interact/favoritedMe" />
|
||||
<el-option label="解锁我 (pages/interact/unlockedMe)" value="pages/interact/unlockedMe" />
|
||||
<el-option label="看过我 (pages/interact/viewedMe)" value="pages/interact/viewedMe" />
|
||||
<el-option label="聊天 (pages/chat/index)" value="pages/chat/index" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item>
|
||||
|
|
@ -475,12 +515,16 @@ const templateForm = ref({
|
|||
encodingAESKey: '',
|
||||
unlockTemplateId: '',
|
||||
unlockFieldMapping: '',
|
||||
unlockPage: '',
|
||||
favoriteTemplateId: '',
|
||||
favoriteFieldMapping: '',
|
||||
favoritePage: '',
|
||||
messageTemplateId: '',
|
||||
messageFieldMapping: '',
|
||||
messagePage: '',
|
||||
dailyRecommendTemplateId: '',
|
||||
dailyRecommendFieldMapping: ''
|
||||
dailyRecommendFieldMapping: '',
|
||||
dailyRecommendPage: ''
|
||||
})
|
||||
|
||||
const saving = ref(false)
|
||||
|
|
@ -759,12 +803,16 @@ const loadNotificationTemplates = async () => {
|
|||
templateForm.value.encodingAESKey = res.encodingAESKey || ''
|
||||
templateForm.value.unlockTemplateId = res.unlockTemplateId || ''
|
||||
templateForm.value.unlockFieldMapping = res.unlockFieldMapping || ''
|
||||
templateForm.value.unlockPage = res.unlockPage || ''
|
||||
templateForm.value.favoriteTemplateId = res.favoriteTemplateId || ''
|
||||
templateForm.value.favoriteFieldMapping = res.favoriteFieldMapping || ''
|
||||
templateForm.value.favoritePage = res.favoritePage || ''
|
||||
templateForm.value.messageTemplateId = res.messageTemplateId || ''
|
||||
templateForm.value.messageFieldMapping = res.messageFieldMapping || ''
|
||||
templateForm.value.messagePage = res.messagePage || ''
|
||||
templateForm.value.dailyRecommendTemplateId = res.dailyRecommendTemplateId || ''
|
||||
templateForm.value.dailyRecommendFieldMapping = res.dailyRecommendFieldMapping || ''
|
||||
templateForm.value.dailyRecommendPage = res.dailyRecommendPage || ''
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('加载模板配置失败:', error)
|
||||
|
|
@ -779,12 +827,16 @@ const saveNotificationTemplates = async () => {
|
|||
encodingAESKey: templateForm.value.encodingAESKey || undefined,
|
||||
unlockTemplateId: templateForm.value.unlockTemplateId || undefined,
|
||||
unlockFieldMapping: templateForm.value.unlockFieldMapping || undefined,
|
||||
unlockPage: templateForm.value.unlockPage || undefined,
|
||||
favoriteTemplateId: templateForm.value.favoriteTemplateId || undefined,
|
||||
favoriteFieldMapping: templateForm.value.favoriteFieldMapping || undefined,
|
||||
favoritePage: templateForm.value.favoritePage || undefined,
|
||||
messageTemplateId: templateForm.value.messageTemplateId || undefined,
|
||||
messageFieldMapping: templateForm.value.messageFieldMapping || undefined,
|
||||
messagePage: templateForm.value.messagePage || undefined,
|
||||
dailyRecommendTemplateId: templateForm.value.dailyRecommendTemplateId || undefined,
|
||||
dailyRecommendFieldMapping: templateForm.value.dailyRecommendFieldMapping || undefined
|
||||
dailyRecommendFieldMapping: templateForm.value.dailyRecommendFieldMapping || undefined,
|
||||
dailyRecommendPage: templateForm.value.dailyRecommendPage || undefined
|
||||
})
|
||||
ElMessage.success('模板配置保存成功')
|
||||
} catch (error) {
|
||||
|
|
|
|||
|
|
@ -549,6 +549,13 @@ public class NotificationService : INotificationService
|
|||
return false;
|
||||
}
|
||||
|
||||
// 从数据库读取跳转页面配置,有配置则覆盖默认值
|
||||
var configuredPage = await GetServiceAccountPageAsync(templateType);
|
||||
if (!string.IsNullOrEmpty(configuredPage))
|
||||
{
|
||||
page = configuredPage;
|
||||
}
|
||||
|
||||
// 从数据库读取字段映射
|
||||
var fieldMapping = await GetServiceAccountFieldMappingAsync(templateType);
|
||||
_logger.LogInformation("服务号字段映射: TemplateType={TemplateType}, FieldMapping={FieldMapping}",
|
||||
|
|
@ -636,6 +643,25 @@ public class NotificationService : INotificationService
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取服务号通知跳转页面配置
|
||||
/// </summary>
|
||||
private async Task<string?> GetServiceAccountPageAsync(NotificationTemplateType templateType)
|
||||
{
|
||||
string? configKey = templateType switch
|
||||
{
|
||||
NotificationTemplateType.Unlock => SystemConfigService.SaUnlockPageKey,
|
||||
NotificationTemplateType.Favorite => SystemConfigService.SaFavoritePageKey,
|
||||
NotificationTemplateType.FirstMessage => SystemConfigService.SaMessagePageKey,
|
||||
NotificationTemplateType.MessageReminder => SystemConfigService.SaMessagePageKey,
|
||||
NotificationTemplateType.DailyRecommend => SystemConfigService.SaDailyRecommendPageKey,
|
||||
_ => null
|
||||
};
|
||||
|
||||
if (configKey == null) return null;
|
||||
return await _configService.GetConfigValueAsync(configKey);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 构建默认模板数据(兜底,数据库未配置字段映射时使用)
|
||||
/// </summary>
|
||||
|
|
|
|||
|
|
@ -102,12 +102,16 @@ public class SystemConfigService : ISystemConfigService
|
|||
public const string SaEncodingAesKeyKey = "sa_encoding_aes_key";
|
||||
public const string SaUnlockTemplateIdKey = "sa_unlock_template_id";
|
||||
public const string SaUnlockFieldMappingKey = "sa_unlock_field_mapping";
|
||||
public const string SaUnlockPageKey = "sa_unlock_page";
|
||||
public const string SaFavoriteTemplateIdKey = "sa_favorite_template_id";
|
||||
public const string SaFavoriteFieldMappingKey = "sa_favorite_field_mapping";
|
||||
public const string SaFavoritePageKey = "sa_favorite_page";
|
||||
public const string SaMessageTemplateIdKey = "sa_message_template_id";
|
||||
public const string SaMessageFieldMappingKey = "sa_message_field_mapping";
|
||||
public const string SaMessagePageKey = "sa_message_page";
|
||||
public const string SaDailyRecommendTemplateIdKey = "sa_daily_recommend_template_id";
|
||||
public const string SaDailyRecommendFieldMappingKey = "sa_daily_recommend_field_mapping";
|
||||
public const string SaDailyRecommendPageKey = "sa_daily_recommend_page";
|
||||
|
||||
public SystemConfigService(
|
||||
IRepository<SystemConfig> configRepository,
|
||||
|
|
@ -365,12 +369,16 @@ public class SystemConfigService : ISystemConfigService
|
|||
EncodingAESKey = await GetConfigValueAsync(SaEncodingAesKeyKey),
|
||||
UnlockTemplateId = await GetConfigValueAsync(SaUnlockTemplateIdKey),
|
||||
UnlockFieldMapping = await GetConfigValueAsync(SaUnlockFieldMappingKey),
|
||||
UnlockPage = await GetConfigValueAsync(SaUnlockPageKey),
|
||||
FavoriteTemplateId = await GetConfigValueAsync(SaFavoriteTemplateIdKey),
|
||||
FavoriteFieldMapping = await GetConfigValueAsync(SaFavoriteFieldMappingKey),
|
||||
FavoritePage = await GetConfigValueAsync(SaFavoritePageKey),
|
||||
MessageTemplateId = await GetConfigValueAsync(SaMessageTemplateIdKey),
|
||||
MessageFieldMapping = await GetConfigValueAsync(SaMessageFieldMappingKey),
|
||||
MessagePage = await GetConfigValueAsync(SaMessagePageKey),
|
||||
DailyRecommendTemplateId = await GetConfigValueAsync(SaDailyRecommendTemplateIdKey),
|
||||
DailyRecommendFieldMapping = await GetConfigValueAsync(SaDailyRecommendFieldMappingKey)
|
||||
DailyRecommendFieldMapping = await GetConfigValueAsync(SaDailyRecommendFieldMappingKey),
|
||||
DailyRecommendPage = await GetConfigValueAsync(SaDailyRecommendPageKey)
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -387,18 +395,26 @@ public class SystemConfigService : ISystemConfigService
|
|||
await SetConfigValueAsync(SaUnlockTemplateIdKey, templates.UnlockTemplateId, "服务号解锁通知模板ID");
|
||||
if (!string.IsNullOrEmpty(templates.UnlockFieldMapping))
|
||||
await SetConfigValueAsync(SaUnlockFieldMappingKey, templates.UnlockFieldMapping, "服务号解锁通知字段映射");
|
||||
if (!string.IsNullOrEmpty(templates.UnlockPage))
|
||||
await SetConfigValueAsync(SaUnlockPageKey, templates.UnlockPage, "服务号解锁通知跳转页面");
|
||||
if (!string.IsNullOrEmpty(templates.FavoriteTemplateId))
|
||||
await SetConfigValueAsync(SaFavoriteTemplateIdKey, templates.FavoriteTemplateId, "服务号收藏通知模板ID");
|
||||
if (!string.IsNullOrEmpty(templates.FavoriteFieldMapping))
|
||||
await SetConfigValueAsync(SaFavoriteFieldMappingKey, templates.FavoriteFieldMapping, "服务号收藏通知字段映射");
|
||||
if (!string.IsNullOrEmpty(templates.FavoritePage))
|
||||
await SetConfigValueAsync(SaFavoritePageKey, templates.FavoritePage, "服务号收藏通知跳转页面");
|
||||
if (!string.IsNullOrEmpty(templates.MessageTemplateId))
|
||||
await SetConfigValueAsync(SaMessageTemplateIdKey, templates.MessageTemplateId, "服务号消息通知模板ID");
|
||||
if (!string.IsNullOrEmpty(templates.MessageFieldMapping))
|
||||
await SetConfigValueAsync(SaMessageFieldMappingKey, templates.MessageFieldMapping, "服务号消息通知字段映射");
|
||||
if (!string.IsNullOrEmpty(templates.MessagePage))
|
||||
await SetConfigValueAsync(SaMessagePageKey, templates.MessagePage, "服务号消息通知跳转页面");
|
||||
if (!string.IsNullOrEmpty(templates.DailyRecommendTemplateId))
|
||||
await SetConfigValueAsync(SaDailyRecommendTemplateIdKey, templates.DailyRecommendTemplateId, "服务号每日推荐通知模板ID");
|
||||
if (!string.IsNullOrEmpty(templates.DailyRecommendFieldMapping))
|
||||
await SetConfigValueAsync(SaDailyRecommendFieldMappingKey, templates.DailyRecommendFieldMapping, "服务号每日推荐通知字段映射");
|
||||
if (!string.IsNullOrEmpty(templates.DailyRecommendPage))
|
||||
await SetConfigValueAsync(SaDailyRecommendPageKey, templates.DailyRecommendPage, "服务号每日推荐通知跳转页面");
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
|
@ -456,10 +472,15 @@ public class NotificationTemplatesDto
|
|||
public string? UnlockTemplateId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 解锁通知字段映射JSON,如 {"thing1":"title","thing2":"name","time3":"time"}
|
||||
/// 解锁通知字段映射JSON
|
||||
/// </summary>
|
||||
public string? UnlockFieldMapping { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 解锁通知跳转页面
|
||||
/// </summary>
|
||||
public string? UnlockPage { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 收藏通知模板ID
|
||||
/// </summary>
|
||||
|
|
@ -470,6 +491,11 @@ public class NotificationTemplatesDto
|
|||
/// </summary>
|
||||
public string? FavoriteFieldMapping { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 收藏通知跳转页面
|
||||
/// </summary>
|
||||
public string? FavoritePage { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 消息通知模板ID(首次消息/未回复提醒共用)
|
||||
/// </summary>
|
||||
|
|
@ -480,6 +506,11 @@ public class NotificationTemplatesDto
|
|||
/// </summary>
|
||||
public string? MessageFieldMapping { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 消息通知跳转页面
|
||||
/// </summary>
|
||||
public string? MessagePage { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 每日推荐通知模板ID
|
||||
/// </summary>
|
||||
|
|
@ -489,4 +520,9 @@ public class NotificationTemplatesDto
|
|||
/// 每日推荐通知字段映射JSON
|
||||
/// </summary>
|
||||
public string? DailyRecommendFieldMapping { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 每日推荐通知跳转页面
|
||||
/// </summary>
|
||||
public string? DailyRecommendPage { get; set; }
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user