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

namespace Atomx.Common.Entities
{
    /// <summary>
    /// 刷新TOKEN
    /// </summary>
    [Table("RefreshTokens")]
    public class RefreshToken
    {
        /// <summary>
        /// 数据ID
        /// </summary>
        [DatabaseGenerated(DatabaseGeneratedOption.None)]
        [Key]
        public string Id { get; set; } = Guid.NewGuid().ToString();

        /// <summary>
        /// 用户ID
        /// </summary>
        public long UserId { get; set; }

        /// <summary>
        /// Token 信息
        /// </summary>
        [Column(TypeName = "varchar(500)")]
        public string Token { get; set; } = string.Empty;

        /// <summary>
        /// 发布时间
        /// </summary>
        [Column(TypeName = "timestamptz")]
        public DateTime IssuedTime { get; set; } = DateTime.UtcNow;

        /// <summary>
        /// 到期时间
        /// </summary>
        [Column(TypeName = "timestamptz")]
        public DateTime ExpiresTime { get; set; }

        /// <summary>
        /// 是否回收
        /// </summary>
        public bool IsRevoked { get; set; }

        /// <summary>
        /// 回收时间
        /// </summary>
        [Column(TypeName = "timestamptz")]
        public DateTime? RevokedTime { get; set; }

        /// <summary>
        /// 用户IP
        /// </summary>
        [Column(TypeName = "varchar(50)")]
        public string Ip { get; set; } = string.Empty;

        /// <summary>
        /// 用户系统代理信息
        /// </summary>
        [Column(TypeName = "varchar(500)")]
        public string UserAgent { get; set; } = string.Empty;
    }
}
