using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace FutureMailAPI.Models
{
    public class SentMail
    {
        [Key]
        public int Id { get; set; }
        
        [Required]
        [MaxLength(200)]
        public string Title { get; set; } = string.Empty;
        
        [Required]
        public string Content { get; set; } = string.Empty;
        
        [Required]
        public int SenderId { get; set; }
        
        // 收件人类型: 0-自己, 1-指定用户, 2-公开时间胶囊
        [Required]
        public int RecipientType { get; set; }
        
        // 如果是指定用户，存储用户ID
        public int? RecipientId { get; set; }
        
        // 发送时间
        public DateTime SentAt { get; set; } = DateTime.UtcNow;
        
        // 投递时间
        [Required]
        public DateTime DeliveryTime { get; set; }
        
        // 邮件状态: 0-草稿, 1-已发送(待投递), 2-投递中, 3-已送达
        [Required]
        public int Status { get; set; } = 0;
        
        // 触发条件类型: 0-时间, 1-地点, 2-事件
        [Required]
        public int TriggerType { get; set; } = 0;
        
        // 触发条件详情(JSON格式存储)
        public string? TriggerDetails { get; set; }
        
        // 附件路径(JSON数组格式)
        public string? Attachments { get; set; }
        
        // 是否加密
        public bool IsEncrypted { get; set; } = false;
        
        // 加密密钥(如果使用端到端加密)
        public string? EncryptionKey { get; set; }
        
        // 邮件主题/胶囊皮肤
        [MaxLength(50)]
        public string? Theme { get; set; }
        
        // 导航属性
        [ForeignKey("SenderId")]
        public virtual User Sender { get; set; } = null!;
        
        public virtual User? Recipient { get; set; }
    }
}