
- 新增通知系统完整架构,包含通知设置、历史记录、任务管理等核心功能 - 实现工作任务分配服务,支持人员和设备的智能分配 - 添加人员分组管理功能,支持灵活的通知目标配置 - 完善相关枚举定义和数据传输对象 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
251 lines
7.2 KiB
C#
251 lines
7.2 KiB
C#
using System.Threading.Tasks;
|
||
using System.Collections.Generic;
|
||
using NPP.SmartSchedue.Api.Contracts.Core.Enums;
|
||
|
||
namespace NPP.SmartSchedue.Api.Contracts.Services.Notification;
|
||
|
||
/// <summary>
|
||
/// 系统消息服务接口
|
||
/// 决策点1:基础通知方式 - 系统消息通知
|
||
/// </summary>
|
||
public interface ISystemMessageService
|
||
{
|
||
#region 单个消息发送
|
||
|
||
/// <summary>
|
||
/// 发送系统消息
|
||
/// </summary>
|
||
/// <param name="recipientPersonnelId">接收人员ID</param>
|
||
/// <param name="title">消息标题</param>
|
||
/// <param name="content">消息内容</param>
|
||
/// <param name="messageType">消息类型(通知、警告、错误等)</param>
|
||
/// <param name="businessType">业务类型</param>
|
||
/// <param name="businessId">业务ID</param>
|
||
/// <returns></returns>
|
||
Task<bool> SendSystemMessageAsync(
|
||
long recipientPersonnelId,
|
||
string title,
|
||
string content,
|
||
SystemMessageTypeEnum messageType = SystemMessageTypeEnum.Info,
|
||
string businessType = "",
|
||
long? businessId = null);
|
||
|
||
/// <summary>
|
||
/// 发送带操作按钮的系统消息
|
||
/// </summary>
|
||
/// <param name="recipientPersonnelId">接收人员ID</param>
|
||
/// <param name="title">消息标题</param>
|
||
/// <param name="content">消息内容</param>
|
||
/// <param name="actions">操作按钮列表</param>
|
||
/// <param name="messageType">消息类型</param>
|
||
/// <param name="businessType">业务类型</param>
|
||
/// <param name="businessId">业务ID</param>
|
||
/// <returns></returns>
|
||
Task<bool> SendSystemMessageWithActionsAsync(
|
||
long recipientPersonnelId,
|
||
string title,
|
||
string content,
|
||
List<SystemMessageAction> actions,
|
||
SystemMessageTypeEnum messageType = SystemMessageTypeEnum.Info,
|
||
string businessType = "",
|
||
long? businessId = null);
|
||
|
||
#endregion
|
||
|
||
#region 批量消息发送
|
||
|
||
/// <summary>
|
||
/// 批量发送系统消息
|
||
/// </summary>
|
||
/// <param name="recipientPersonnelIds">接收人员ID列表</param>
|
||
/// <param name="title">消息标题</param>
|
||
/// <param name="content">消息内容</param>
|
||
/// <param name="messageType">消息类型</param>
|
||
/// <param name="businessType">业务类型</param>
|
||
/// <param name="businessId">业务ID</param>
|
||
/// <returns>发送结果,Key为人员ID,Value为是否发送成功</returns>
|
||
Task<Dictionary<long, bool>> BatchSendSystemMessageAsync(
|
||
List<long> recipientPersonnelIds,
|
||
string title,
|
||
string content,
|
||
SystemMessageTypeEnum messageType = SystemMessageTypeEnum.Info,
|
||
string businessType = "",
|
||
long? businessId = null);
|
||
|
||
/// <summary>
|
||
/// 个性化批量发送系统消息
|
||
/// 每个收件人可以有不同的消息内容
|
||
/// </summary>
|
||
/// <param name="messageItems">消息项列表</param>
|
||
/// <returns>发送结果,Key为人员ID,Value为是否发送成功</returns>
|
||
Task<Dictionary<long, bool>> BatchSendPersonalizedSystemMessageAsync(List<SystemMessageItem> messageItems);
|
||
|
||
#endregion
|
||
|
||
#region 消息模板
|
||
|
||
/// <summary>
|
||
/// 使用模板发送系统消息
|
||
/// </summary>
|
||
/// <param name="recipientPersonnelId">接收人员ID</param>
|
||
/// <param name="titleTemplate">消息标题模板</param>
|
||
/// <param name="contentTemplate">消息内容模板</param>
|
||
/// <param name="variables">模板变量</param>
|
||
/// <param name="messageType">消息类型</param>
|
||
/// <param name="businessType">业务类型</param>
|
||
/// <param name="businessId">业务ID</param>
|
||
/// <returns></returns>
|
||
Task<bool> SendSystemMessageByTemplateAsync(
|
||
long recipientPersonnelId,
|
||
string titleTemplate,
|
||
string contentTemplate,
|
||
Dictionary<string, string> variables,
|
||
SystemMessageTypeEnum messageType = SystemMessageTypeEnum.Info,
|
||
string businessType = "",
|
||
long? businessId = null);
|
||
|
||
#endregion
|
||
|
||
#region 消息管理
|
||
|
||
/// <summary>
|
||
/// 标记消息为已读
|
||
/// </summary>
|
||
/// <param name="messageId">消息ID</param>
|
||
/// <param name="recipientPersonnelId">接收人员ID</param>
|
||
/// <returns></returns>
|
||
Task<bool> MarkMessageAsReadAsync(long messageId, long recipientPersonnelId);
|
||
|
||
/// <summary>
|
||
/// 批量标记消息为已读
|
||
/// </summary>
|
||
/// <param name="messageIds">消息ID列表</param>
|
||
/// <param name="recipientPersonnelId">接收人员ID</param>
|
||
/// <returns></returns>
|
||
Task<int> BatchMarkMessagesAsReadAsync(List<long> messageIds, long recipientPersonnelId);
|
||
|
||
/// <summary>
|
||
/// 删除消息
|
||
/// </summary>
|
||
/// <param name="messageId">消息ID</param>
|
||
/// <param name="recipientPersonnelId">接收人员ID</param>
|
||
/// <returns></returns>
|
||
Task<bool> DeleteMessageAsync(long messageId, long recipientPersonnelId);
|
||
|
||
/// <summary>
|
||
/// 获取用户未读消息数量
|
||
/// </summary>
|
||
/// <param name="recipientPersonnelId">接收人员ID</param>
|
||
/// <returns></returns>
|
||
Task<int> GetUnreadMessageCountAsync(long recipientPersonnelId);
|
||
|
||
#endregion
|
||
}
|
||
|
||
/// <summary>
|
||
/// 系统消息类型枚举
|
||
/// </summary>
|
||
public enum SystemMessageTypeEnum
|
||
{
|
||
/// <summary>
|
||
/// 信息
|
||
/// </summary>
|
||
Info = 1,
|
||
|
||
/// <summary>
|
||
/// 成功
|
||
/// </summary>
|
||
Success = 2,
|
||
|
||
/// <summary>
|
||
/// 警告
|
||
/// </summary>
|
||
Warning = 3,
|
||
|
||
/// <summary>
|
||
/// 错误
|
||
/// </summary>
|
||
Error = 4,
|
||
|
||
/// <summary>
|
||
/// 紧急
|
||
/// </summary>
|
||
Urgent = 5
|
||
}
|
||
|
||
/// <summary>
|
||
/// 系统消息项
|
||
/// </summary>
|
||
public class SystemMessageItem
|
||
{
|
||
/// <summary>
|
||
/// 接收人员ID
|
||
/// </summary>
|
||
public long RecipientPersonnelId { get; set; }
|
||
|
||
/// <summary>
|
||
/// 消息标题
|
||
/// </summary>
|
||
public string Title { get; set; } = "";
|
||
|
||
/// <summary>
|
||
/// 消息内容
|
||
/// </summary>
|
||
public string Content { get; set; } = "";
|
||
|
||
/// <summary>
|
||
/// 消息类型
|
||
/// </summary>
|
||
public SystemMessageTypeEnum MessageType { get; set; } = SystemMessageTypeEnum.Info;
|
||
|
||
/// <summary>
|
||
/// 业务类型
|
||
/// </summary>
|
||
public string BusinessType { get; set; } = "";
|
||
|
||
/// <summary>
|
||
/// 业务ID
|
||
/// </summary>
|
||
public long? BusinessId { get; set; }
|
||
|
||
/// <summary>
|
||
/// 操作按钮列表
|
||
/// </summary>
|
||
public List<SystemMessageAction> Actions { get; set; } = new List<SystemMessageAction>();
|
||
|
||
/// <summary>
|
||
/// 个性化变量
|
||
/// </summary>
|
||
public Dictionary<string, string> Variables { get; set; } = new Dictionary<string, string>();
|
||
}
|
||
|
||
/// <summary>
|
||
/// 系统消息操作按钮
|
||
/// </summary>
|
||
public class SystemMessageAction
|
||
{
|
||
/// <summary>
|
||
/// 操作ID
|
||
/// </summary>
|
||
public string ActionId { get; set; } = "";
|
||
|
||
/// <summary>
|
||
/// 操作名称
|
||
/// </summary>
|
||
public string ActionName { get; set; } = "";
|
||
|
||
/// <summary>
|
||
/// 操作URL
|
||
/// </summary>
|
||
public string ActionUrl { get; set; } = "";
|
||
|
||
/// <summary>
|
||
/// 操作类型(按钮、链接等)
|
||
/// </summary>
|
||
public string ActionType { get; set; } = "button";
|
||
|
||
/// <summary>
|
||
/// 是否主要操作
|
||
/// </summary>
|
||
public bool IsPrimary { get; set; } = false;
|
||
} |