using System.ComponentModel.DataAnnotations;

namespace DMS.Core.Models
{
    /// <summary>
    /// 邮件消息实体
    /// </summary>
    public class EmailMessage
    {
        /// <summary>
        /// 邮件ID
        /// </summary>
        public int Id { get; set; }

        /// <summary>
        /// 关联的邮件账户ID
        /// </summary>
        public int EmailAccountId { get; set; }

        /// <summary>
        /// 发件人邮箱地址
        /// </summary>
        [Required]
        [MaxLength(255)]
        public string From { get; set; }

        /// <summary>
        /// 收件人邮箱地址（多个用分号分隔）
        /// </summary>
        [Required]
        [MaxLength(1000)]
        public string To { get; set; }

        /// <summary>
        /// 抄送邮箱地址（多个用分号分隔）
        /// </summary>
        [MaxLength(1000)]
        public string? Cc { get; set; }

        /// <summary>
        /// 密送邮箱地址（多个用分号分隔）
        /// </summary>
        [MaxLength(1000)]
        public string? Bcc { get; set; }

        /// <summary>
        /// 邮件主题
        /// </summary>
        [Required]
        [MaxLength(500)]
        public string Subject { get; set; }

        /// <summary>
        /// 邮件正文
        /// </summary>
        [Required]
        public string Body { get; set; }

        /// <summary>
        /// 是否为HTML格式
        /// </summary>
        public bool IsHtml { get; set; } = true;

        /// <summary>
        /// 邮件发送状态
        /// </summary>
        public EmailSendStatus Status { get; set; } = EmailSendStatus.Pending;

        /// <summary>
        /// 发送时间
        /// </summary>
        public DateTime? SentAt { get; set; }

        /// <summary>
        /// 创建时间
        /// </summary>
        public DateTime CreatedAt { get; set; } = DateTime.Now;

        /// <summary>
        /// 更新时间
        /// </summary>
        public DateTime UpdatedAt { get; set; } = DateTime.Now;
    }

    /// <summary>
    /// 邮件发送状态枚举
    /// </summary>
    public enum EmailSendStatus
    {
        /// <summary>
        /// 待发送
        /// </summary>
        Pending,

        /// <summary>
        /// 发送成功
        /// </summary>
        Sent,

        /// <summary>
        /// 发送失败
        /// </summary>
        Failed
    }
}