diff --git a/src/SJZY.Track.Application/Hangfire/NotifyConfig.cs b/src/SJZY.Track.Application/Hangfire/NotifyConfig.cs new file mode 100644 index 00000000..53a3327e --- /dev/null +++ b/src/SJZY.Track.Application/Hangfire/NotifyConfig.cs @@ -0,0 +1,63 @@ +namespace SJZY.Track.Application.Hangfire; + +// 发送消息接口参数 +// https://centerapi.test.shijizhongyun.com/userApi/index.html?urls.primaryName=%E6%B6%88%E6%81%AF%E8%AE%A2%E9%98%85%E5%AE%9E%E4%BE%8B +/// MsgSubscribeInstance/SendMessageByTemplate +public class NotifyConfig +{ + private const string ContentKey = "content"; //内容参数 + + public bool IsNeedToHandle { get; set; } = true; //是否需要处理(默认为未处理,传false为无需处理,针对站内信是否处理功能) + public int MsgSource { get; set; } // 消息来源:1.消息 2.任务 3.流程 4.消息提醒 + public int SystemId { get; set; } = 9498; //子系统id 业务中台 + public string TemplateCode { get; set; } = "TrackWarningNotify"; //模板code + public List Channels { get; set; } //1:站内信 2.飞书 4.邮箱 8.短信 16.语音播报 + public List Variables { get; set; } //模板参数 + public List Receivers { get; set; } + + public sealed record Variable(string Key, string Value); + + public sealed record Receiver( + int ReceiverId, //接收人id : 内部用户Id,外部用户Id,或只有邮箱跟短信时不需要接收人Id + int RecipientType = 1, //接收人类型 (1:内部用户 2.外部用户) + string? ReceiverName = null, //接收人姓名 + string? Mail = null, //邮箱 + string? MobilePhone = null //手机号 + ); + + public static NotifyConfig CreateConfig(int userId, string message, List notifyModes) + { + return new NotifyConfig + { + Channels = notifyModes, + Receivers = new List(1) + { + new Receiver(userId) + }, + Variables = new List(1) + { + new Variable(ContentKey, message) + } + }; + } + + public static NotifyConfig CreateConfig(int userId, string message) + { + return new NotifyConfig + { + Channels = new List(2) + { + 1, + 2 + }, + Receivers = new List + { + new Receiver(userId) + }, + Variables = new List + { + new Variable(ContentKey, message) + } + }; + } +}