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

namespace FutureMailAPI.Models
{
    public class User
    {
        [Key]
        public int Id { get; set; }
        
        [Required]
        [MaxLength(100)]
        public string Username { get; set; } = string.Empty;
        
        [Required]
        [MaxLength(255)]
        public string Email { get; set; } = string.Empty;
        
        [Required]
        [MaxLength(255)]
        public string PasswordHash { get; set; } = string.Empty;
        
        [Required]
        [MaxLength(255)]
        public string Salt { get; set; } = string.Empty;
        
        [MaxLength(100)]
        public string? Nickname { get; set; }
        
        [MaxLength(500)]
        public string? Avatar { get; set; }
        
        public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
        
        public DateTime? LastLoginAt { get; set; }
        
        public bool IsActive { get; set; } = true;
        
        [MaxLength(20)]
        public string? PreferredScene { get; set; } = "SPACE";
        
        [MaxLength(50)]
        public string? PreferredBackground { get; set; } = "default";
        
        [MaxLength(500)]
        public string? RefreshToken { get; set; }
        
        public DateTime? RefreshTokenExpiryTime { get; set; }

        
        // 导航属性
        public virtual ICollection<SentMail> SentMails { get; set; } = new List<SentMail>();
        public virtual ICollection<ReceivedMail> ReceivedMails { get; set; } = new List<ReceivedMail>();
        public virtual ICollection<TimeCapsule> TimeCapsules { get; set; } = new List<TimeCapsule>();
    }
}