first commit

This commit is contained in:
yanpeng200212
2026-10-08 10:43:59 +08:00
commit 8430ba0452
288 changed files with 29595 additions and 0 deletions
@@ -0,0 +1,64 @@
namespace F9WebAiTest.Domain.Entities.Notice;
/// <summary>消息优先级</summary>
public enum NotificationPriority
{
Normal = 0, // 普通
Important = 1, // 重要
Urgent = 2 // 紧急
}
/// <summary>消息状态</summary>
public enum NotificationStatus
{
Ready = 0, // 准备(待投递)
Sent = 1, // 已发送
Failed = 2, // 失败
PartialSuccess = 3, // 部分成功
Revoked = 4 // 已撤销
}
/// <summary>阅读状态</summary>
public enum NotificationReadStatus
{
Unread = 0, // 未读
Read = 1 // 已读
}
/// <summary>推送状态</summary>
public enum NotificationSendStatus
{
NotSent = 0, // 未发送
Success = 1, // 成功
Failed = 2 // 失败
}
/// <summary>待办状态</summary>
public enum TodoItemStatus
{
Pending = 0, // 待处理
Processing = 1, // 处理中
Completed = 2, // 已完成
Cancelled = 3 // 已取消
}
/// <summary>消息分类(决定消息中心展示形态与处理方式)</summary>
public enum NotificationCategory
{
Notification = 0, // 通知:纯提醒,点开查看/标记已读
Todo = 1, // 待办:需用户处理(审批/任务),关联待办事项
Announcement = 2 // 公告:广播给全体,重点展示
}
/// <summary>
/// 消息类型枚举(枚举名与 NotificationType.Code 一一对应)。
/// 业务侧通过「该枚举 + MediatR 命令」发送消息,无需关心底层实现。
/// 新增消息类型时:1) 在此加枚举值 2) 在数据库/种子中配置同名 Code 的消息类型(标题、路由模板、接收规则等)。
/// </summary>
public enum NotificationTypeEnum
{
TeyeFound = 1, // 发现特野
TdcFound = 2, // 发现特大糙
LeaveApproval = 3, // 请假审批(待办)
LeaveResult = 4 // 请假结果通知(通知)
}
@@ -0,0 +1,27 @@
using FreeSql.DataAnnotations;
using F9WebAiTest.Domain.Common;
namespace F9WebAiTest.Domain.Entities.Notice;
/// <summary>消息主表(业务系统触发创建,创建时即时投递并实时推送)</summary>
[Table(Name = "NotificationMessages")]
[Index("IX_NotificationMessages_MessageTypeCode", "MessageTypeCode")]
public class NotificationMessage : BaseEntity
{
public long NotificationTypeId { get; set; } // 消息类型ID
public string MessageTypeCode { get; set; } = ""; // 消息类型编码(冗余,路由查询免联表)
public string BusinessType { get; set; } = ""; // 业务类型标识
public string BusinessId { get; set; } = ""; // 业务单据ID
public string Title { get; set; } = ""; // 标题
public string Content { get; set; } = ""; // 内容
public NotificationPriority Priority { get; set; } = NotificationPriority.Normal; // 优先级
public NotificationStatus Status { get; set; } = NotificationStatus.Ready; // 状态
public int RetryCount { get; set; } // 重试次数
public int MaxRetryCount { get; set; } = 3; // 最大重试次数
public string BizContext { get; set; } = ""; // 业务上下文(JSON)
public string ForceReceivers { get; set; } = ""; // 强制接收人(JSON 数组,如 "[1001,1002]"),空=仅按订阅
public long CreatorId { get; set; } // 创建人ID
public string CreatorName { get; set; } = ""; // 创建人姓名
public NotificationCategory Category { get; set; } = NotificationCategory.Notification; // 消息分类(冗余,前端免联表)
public string RoutePath { get; set; } = ""; // Web 端跳转路由(最终值,由模板+业务ID生成)
}
@@ -0,0 +1,20 @@
using FreeSql.DataAnnotations;
using F9WebAiTest.Domain.Common;
namespace F9WebAiTest.Domain.Entities.Notice;
/// <summary>消息接收人(投递时生成,记录阅读状态与推送结果:在线推送成功 / 离线待拉取)</summary>
[Table(Name = "NotificationReceivers")]
[Index("IX_NotificationReceivers_MessageId_UserId", "MessageId, UserId", IsUnique = true)]
[Index("IX_NotificationReceivers_UserId_ReadStatus", "UserId, ReadStatus")]
public class NotificationReceiver : BaseEntity
{
public long MessageId { get; set; } // 消息ID
public long UserId { get; set; } // 接收人用户ID
public NotificationReadStatus ReadStatus { get; set; } = NotificationReadStatus.Unread; // 阅读状态
public DateTime? ReadTime { get; set; } // 阅读时间
public bool IsOffline { get; set; } // 推送时是否离线
public NotificationSendStatus SendStatus { get; set; } = NotificationSendStatus.NotSent; // 推送状态
public DateTime? SendTime { get; set; } // 推送时间
public string ErrorMsg { get; set; } = ""; // 错误信息
}
@@ -0,0 +1,21 @@
using FreeSql.DataAnnotations;
using F9WebAiTest.Domain.Common;
namespace F9WebAiTest.Domain.Entities.Notice;
/// <summary>消息类型(管理员维护,定义订阅所需权限)</summary>
[Table(Name = "NotificationTypes")]
[Index("IX_NotificationTypes_Code", "Code", IsUnique = true)]
public class NotificationType : BaseEntity
{
public string Code { get; set; } = ""; // 消息类型编码,唯一,如 "TeyeFound"
public string Name { get; set; } = ""; // 消息类型名称,如 "发现特野"
public string Description { get; set; } = ""; // 类型描述,展示在订阅页
public string RequiredPermission { get; set; } = ""; // 订阅该类型所需权限码,空=所有用户可订阅
public bool IsActive { get; set; } = true; // 是否开放订阅
public long CreatedBy { get; set; } // 创建人ID
public int Sort { get; set; } // 排序号
public NotificationCategory Category { get; set; } = NotificationCategory.Notification; // 消息分类
public string Icon { get; set; } = ""; // 图标(Element Plus 图标名,如 "Bell")
public string RouteTemplate { get; set; } = ""; // Web 端跳转路由模板,支持 {businessId} 占位符
}
@@ -0,0 +1,17 @@
using FreeSql.DataAnnotations;
using F9WebAiTest.Domain.Common;
namespace F9WebAiTest.Domain.Entities.Notice;
/// <summary>待办事项(消息可携带待办)</summary>
[Table(Name = "TodoItems")]
[Index("IX_TodoItems_AssigneeId_TodoStatus", "AssigneeId, TodoStatus")]
public class TodoItem : BaseEntity
{
public long MessageId { get; set; } // 关联消息ID
public long AssigneeId { get; set; } // 处理人用户ID
public TodoItemStatus TodoStatus { get; set; } = TodoItemStatus.Pending; // 待办状态
public DateTime? DueTime { get; set; } // 截止时间
public DateTime? CompletedTime { get; set; } // 完成时间
public string HandleResult { get; set; } = ""; // 处理结果
}
@@ -0,0 +1,16 @@
using FreeSql.DataAnnotations;
using F9WebAiTest.Domain.Common;
namespace F9WebAiTest.Domain.Entities.Notice;
/// <summary>用户订阅(用户主动订阅/取消,保留历史)</summary>
[Table(Name = "UserNotificationSubscriptions")]
[Index("IX_UserNotificationSubscriptions_UserId_NotificationTypeId", "UserId, NotificationTypeId", IsUnique = true)]
public class UserNotificationSubscription : BaseEntity
{
public long UserId { get; set; } // 订阅用户ID
public long NotificationTypeId { get; set; } // 消息类型ID
public bool IsActive { get; set; } = true; // 订阅状态:true=已订阅 false=已取消
public DateTime SubscribedTime { get; set; } = DateTime.Now; // 订阅时间
public DateTime? CancelTime { get; set; } // 取消订阅时间
}