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;
///
/// 通知历史记录实体
/// 决策点8:简单记录,记录发送时间、接收人、成功失败状态
/// 决策点5:不支持多租户,继承EntityBase
///
[Table(Name = DbConsts.TableNamePrefix + "notification_history")]
public partial class NotificationHistoryEntity : EntityBase
{
#region 关联信息
///
/// 通知设置ID
///
[Required(ErrorMessage = "通知设置ID不能为空")]
public long NotificationSettingId { get; set; }
///
/// 接收人员ID
///
[Required(ErrorMessage = "接收人员ID不能为空")]
public long RecipientPersonnelId { get; set; }
///
/// 接收人员姓名
///
[Column(StringLength = 100)]
public string RecipientPersonnelName { get; set; } = "";
///
/// 接收人员邮箱
///
[Column(StringLength = 200)]
public string RecipientEmail { get; set; } = "";
#endregion
#region 通知内容
///
/// 通知方式
///
public int NotificationType { get; set; }
///
/// 通知标题
///
[Column(StringLength = 500)]
public string NotificationTitle { get; set; } = "";
///
/// 通知内容
///
[Column(DbType = "text")]
public string NotificationContent { get; set; } = "";
#endregion
#region 发送信息
///
/// 计划发送时间
///
public DateTime PlannedSendTime { get; set; }
///
/// 实际发送时间
///
public DateTime? ActualSendTime { get; set; }
///
/// 发送状态
///
public int SendStatus { get; set; } = (int)NotificationStatusEnum.Pending;
///
/// 发送结果信息
///
[Column(StringLength = 1000)]
public string SendResult { get; set; } = "";
///
/// 错误信息
///
[Column(StringLength = 1000)]
public string ErrorMessage { get; set; } = "";
#endregion
#region 重试机制
///
/// 重试次数
///
public int RetryCount { get; set; } = 0;
///
/// 最大重试次数
///
public int MaxRetryCount { get; set; } = 3;
///
/// 下次重试时间
///
public DateTime? NextRetryTime { get; set; }
#endregion
#region 业务上下文
///
/// 业务类型(如:工作任务、设备维护等)
///
[Column(StringLength = 100)]
public string BusinessType { get; set; } = "";
///
/// 业务ID(如:工作任务ID、设备ID等)
///
public long? BusinessId { get; set; }
///
/// 业务数据(JSON格式存储相关业务信息)
///
[Column(DbType = "text")]
public string BusinessData { get; set; } = "";
#endregion
#region 导航属性
///
/// 通知设置实体
///
[Navigate("NotificationSettingId")]
public NotificationSettingEntity? NotificationSetting { get; set; }
#endregion
}