using System; using System.ComponentModel.DataAnnotations; using FreeSql.DataAnnotations; using ZhonTai.Admin.Core.Entities; using NPP.SmartSchedue.Api.Contracts.Core.Consts; using NPP.SmartSchedue.Api.Contracts.Core.Enums; namespace NPP.SmartSchedue.Api.Contracts.Domain.Notification; /// /// 通知设置实体 /// 根据决策点5,通知设置不支持多租户,继承EntityBase /// [Table(Name = DbConsts.TableNamePrefix + "notification_setting")] public partial class NotificationSettingEntity : EntityBase { #region 基础信息 /// /// 通知名称 /// [Column(StringLength = 200)] [Required(ErrorMessage = "通知名称不能为空")] public string NotificationName { get; set; } = ""; /// /// 通知描述 /// [Column(StringLength = 500)] public string Description { get; set; } = ""; /// /// 是否启用 /// public bool IsEnabled { get; set; } = true; #endregion #region 通知方式配置(决策点1:支持邮件和系统消息) /// /// 通知方式(支持多选,使用位运算) /// public int NotificationTypes { get; set; } /// /// 是否启用邮件通知 /// [Column(MapType = typeof(bool), IsIgnore = true)] public bool IsEmailEnabled { get => (NotificationTypes & (int)NotificationTypeEnum.Email) != 0; set { if (value) NotificationTypes |= (int)NotificationTypeEnum.Email; else NotificationTypes &= ~(int)NotificationTypeEnum.Email; } } /// /// 是否启用系统消息通知 /// [Column(MapType = typeof(bool), IsIgnore = true)] public bool IsSystemMessageEnabled { get => (NotificationTypes & (int)NotificationTypeEnum.SystemMessage) != 0; set { if (value) NotificationTypes |= (int)NotificationTypeEnum.SystemMessage; else NotificationTypes &= ~(int)NotificationTypeEnum.SystemMessage; } } #endregion #region 时间配置(决策点2:简单时间段 开始时间-结束时间) /// /// 通知开始时间(HH:mm格式,如:09:00) /// [Column(StringLength = 10)] [Required(ErrorMessage = "通知开始时间不能为空")] public string StartTime { get; set; } = ""; /// /// 通知结束时间(HH:mm格式,如:18:00) /// [Column(StringLength = 10)] [Required(ErrorMessage = "通知结束时间不能为空")] public string EndTime { get; set; } = ""; #endregion #region 频次配置(决策点3:一次性 vs 固定间隔) /// /// 通知频次类型 /// public int FrequencyType { get; set; } = (int)NotificationFrequencyEnum.Once; /// /// 间隔时间(分钟) /// 当FrequencyType为FixedInterval时有效 /// public int? IntervalMinutes { get; set; } #endregion #region 人员组配置 /// /// 关联的人员组ID /// [Required(ErrorMessage = "人员组不能为空")] public long PersonnelGroupId { get; set; } #endregion #region 模板配置(决策点7:支持模板通知) /// /// 邮件主题模板 /// [Column(StringLength = 500)] public string EmailSubjectTemplate { get; set; } = ""; /// /// 邮件内容模板 /// [Column(DbType = "text")] public string EmailContentTemplate { get; set; } = ""; /// /// 系统消息标题模板 /// [Column(StringLength = 500)] public string SystemMessageTitleTemplate { get; set; } = ""; /// /// 系统消息内容模板 /// [Column(DbType = "text")] public string SystemMessageContentTemplate { get; set; } = ""; #endregion #region 触发条件 /// /// 触发条件表达式(JSON格式存储) /// 用于定义什么条件下触发通知 /// [Column(DbType = "text")] public string TriggerConditions { get; set; } = ""; #endregion #region 创建和修改时间 /// /// 最后修改时间 /// public DateTime? LastModifiedTime { get; set; } #endregion #region 导航属性 /// /// 人员组实体 /// [Navigate("PersonnelGroupId")] public PersonnelGroupEntity? PersonnelGroup { get; set; } #endregion }