
- 新增通知系统完整架构,包含通知设置、历史记录、任务管理等核心功能 - 实现工作任务分配服务,支持人员和设备的智能分配 - 添加人员分组管理功能,支持灵活的通知目标配置 - 完善相关枚举定义和数据传输对象 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
240 lines
6.1 KiB
C#
240 lines
6.1 KiB
C#
using System.Collections.Generic;
|
||
using System.Threading.Tasks;
|
||
|
||
namespace NPP.SmartSchedue.Api.Contracts.Services.Notification;
|
||
|
||
/// <summary>
|
||
/// 通知模板服务接口
|
||
/// 决策点7:模板通知,支持通知内容模板,可替换变量
|
||
/// </summary>
|
||
public interface INotificationTemplateService
|
||
{
|
||
#region 模板渲染
|
||
|
||
/// <summary>
|
||
/// 渲染通知模板
|
||
/// 支持变量替换,如:{变量名}
|
||
/// </summary>
|
||
/// <param name="template">模板内容</param>
|
||
/// <param name="variables">变量字典</param>
|
||
/// <returns>渲染后的内容</returns>
|
||
Task<string> RenderTemplateAsync(string template, Dictionary<string, string> variables);
|
||
|
||
/// <summary>
|
||
/// 同步渲染通知模板
|
||
/// </summary>
|
||
/// <param name="template">模板内容</param>
|
||
/// <param name="variables">变量字典</param>
|
||
/// <returns>渲染后的内容</returns>
|
||
string RenderTemplate(string template, Dictionary<string, string> variables);
|
||
|
||
#endregion
|
||
|
||
#region 模板验证
|
||
|
||
/// <summary>
|
||
/// 验证模板语法是否正确
|
||
/// </summary>
|
||
/// <param name="template">模板内容</param>
|
||
/// <returns>验证结果</returns>
|
||
Task<TemplateValidationResult> ValidateTemplateAsync(string template);
|
||
|
||
/// <summary>
|
||
/// 同步验证模板语法
|
||
/// </summary>
|
||
/// <param name="template">模板内容</param>
|
||
/// <returns>验证结果</returns>
|
||
TemplateValidationResult ValidateTemplate(string template);
|
||
|
||
#endregion
|
||
|
||
#region 变量解析
|
||
|
||
/// <summary>
|
||
/// 提取模板中的变量列表
|
||
/// </summary>
|
||
/// <param name="template">模板内容</param>
|
||
/// <returns>变量名列表</returns>
|
||
Task<List<string>> ExtractVariablesAsync(string template);
|
||
|
||
/// <summary>
|
||
/// 同步提取模板中的变量列表
|
||
/// </summary>
|
||
/// <param name="template">模板内容</param>
|
||
/// <returns>变量名列表</returns>
|
||
List<string> ExtractVariables(string template);
|
||
|
||
#endregion
|
||
|
||
#region 内置变量
|
||
|
||
/// <summary>
|
||
/// 获取系统内置变量
|
||
/// </summary>
|
||
/// <returns>内置变量字典</returns>
|
||
Task<Dictionary<string, string>> GetSystemVariablesAsync();
|
||
|
||
/// <summary>
|
||
/// 获取业务相关变量
|
||
/// </summary>
|
||
/// <param name="businessType">业务类型</param>
|
||
/// <param name="businessId">业务ID</param>
|
||
/// <param name="businessData">业务数据</param>
|
||
/// <returns>业务变量字典</returns>
|
||
Task<Dictionary<string, string>> GetBusinessVariablesAsync(
|
||
string businessType,
|
||
long? businessId = null,
|
||
string businessData = "");
|
||
|
||
#endregion
|
||
|
||
#region 模板预定义
|
||
|
||
/// <summary>
|
||
/// 获取预定义模板列表
|
||
/// </summary>
|
||
/// <param name="category">模板分类</param>
|
||
/// <returns>预定义模板列表</returns>
|
||
Task<List<PredefinedTemplate>> GetPredefinedTemplatesAsync(string category = "");
|
||
|
||
/// <summary>
|
||
/// 获取指定预定义模板
|
||
/// </summary>
|
||
/// <param name="templateId">模板ID</param>
|
||
/// <returns>预定义模板</returns>
|
||
Task<PredefinedTemplate> GetPredefinedTemplateAsync(string templateId);
|
||
|
||
#endregion
|
||
}
|
||
|
||
/// <summary>
|
||
/// 模板验证结果
|
||
/// </summary>
|
||
public class TemplateValidationResult
|
||
{
|
||
/// <summary>
|
||
/// 是否验证通过
|
||
/// </summary>
|
||
public bool IsValid { get; set; } = true;
|
||
|
||
/// <summary>
|
||
/// 错误信息列表
|
||
/// </summary>
|
||
public List<string> Errors { get; set; } = new List<string>();
|
||
|
||
/// <summary>
|
||
/// 警告信息列表
|
||
/// </summary>
|
||
public List<string> Warnings { get; set; } = new List<string>();
|
||
|
||
/// <summary>
|
||
/// 发现的变量列表
|
||
/// </summary>
|
||
public List<string> Variables { get; set; } = new List<string>();
|
||
|
||
/// <summary>
|
||
/// 添加错误信息
|
||
/// </summary>
|
||
/// <param name="error">错误信息</param>
|
||
public void AddError(string error)
|
||
{
|
||
IsValid = false;
|
||
Errors.Add(error);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 添加警告信息
|
||
/// </summary>
|
||
/// <param name="warning">警告信息</param>
|
||
public void AddWarning(string warning)
|
||
{
|
||
Warnings.Add(warning);
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 预定义模板
|
||
/// </summary>
|
||
public class PredefinedTemplate
|
||
{
|
||
/// <summary>
|
||
/// 模板ID
|
||
/// </summary>
|
||
public string TemplateId { get; set; } = "";
|
||
|
||
/// <summary>
|
||
/// 模板名称
|
||
/// </summary>
|
||
public string TemplateName { get; set; } = "";
|
||
|
||
/// <summary>
|
||
/// 模板分类
|
||
/// </summary>
|
||
public string Category { get; set; } = "";
|
||
|
||
/// <summary>
|
||
/// 模板描述
|
||
/// </summary>
|
||
public string Description { get; set; } = "";
|
||
|
||
/// <summary>
|
||
/// 邮件主题模板
|
||
/// </summary>
|
||
public string EmailSubjectTemplate { get; set; } = "";
|
||
|
||
/// <summary>
|
||
/// 邮件内容模板
|
||
/// </summary>
|
||
public string EmailContentTemplate { get; set; } = "";
|
||
|
||
/// <summary>
|
||
/// 系统消息标题模板
|
||
/// </summary>
|
||
public string SystemMessageTitleTemplate { get; set; } = "";
|
||
|
||
/// <summary>
|
||
/// 系统消息内容模板
|
||
/// </summary>
|
||
public string SystemMessageContentTemplate { get; set; } = "";
|
||
|
||
/// <summary>
|
||
/// 支持的变量列表
|
||
/// </summary>
|
||
public List<TemplateVariable> SupportedVariables { get; set; } = new List<TemplateVariable>();
|
||
}
|
||
|
||
/// <summary>
|
||
/// 模板变量定义
|
||
/// </summary>
|
||
public class TemplateVariable
|
||
{
|
||
/// <summary>
|
||
/// 变量名
|
||
/// </summary>
|
||
public string Name { get; set; } = "";
|
||
|
||
/// <summary>
|
||
/// 变量描述
|
||
/// </summary>
|
||
public string Description { get; set; } = "";
|
||
|
||
/// <summary>
|
||
/// 变量类型
|
||
/// </summary>
|
||
public string Type { get; set; } = "string";
|
||
|
||
/// <summary>
|
||
/// 是否必需
|
||
/// </summary>
|
||
public bool IsRequired { get; set; } = false;
|
||
|
||
/// <summary>
|
||
/// 默认值
|
||
/// </summary>
|
||
public string DefaultValue { get; set; } = "";
|
||
|
||
/// <summary>
|
||
/// 示例值
|
||
/// </summary>
|
||
public string ExampleValue { get; set; } = "";
|
||
} |