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

namespace FutureMailAPI.Models
{
    public class OAuthToken
    {
        [Key]
        public int Id { get; set; }
        
        [Required]
        [MaxLength(255)]
        public string AccessToken { get; set; } = string.Empty;
        
        [Required]
        [MaxLength(255)]
        public string RefreshToken { get; set; } = string.Empty;
        
        [Required]
        public string TokenType { get; set; } = "Bearer";
        
        public DateTime ExpiresAt { get; set; }
        
        public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
        
        public DateTime? UpdatedAt { get; set; }
        
        public DateTime? RevokedAt { get; set; }
        
        public string? Scope { get; set; }
        
        // 外键
        public int UserId { get; set; }
        
        public int ClientId { get; set; }
        
        // 导航属性
        [ForeignKey("UserId")]
        public virtual User User { get; set; } = null!;
        
        [ForeignKey("ClientId")]
        public virtual OAuthClient Client { get; set; } = null!;
    }
}