flower-story/Server/Data/Model/TokenItem.cs
2023-07-13 12:10:30 +08:00

104 lines
2.4 KiB
C#

using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Text.Json.Serialization;
namespace Blahblah.FlowerStory.Server.Data.Model;
/// <summary>
/// 会话令牌对象
/// </summary>
[Table("tokens")]
public class TokenItem
{
/// <summary>
/// token 唯一 id
/// </summary>
[Column("tid")]
[Key]
[Required]
public required string Id { get; set; }
/// <summary>
/// 关联用户 uid
/// </summary>
[Column("uid")]
[Required]
public required int UserId { get; set; }
/// <summary>
/// 登录时间
/// </summary>
[Column("logondate")]
[Required]
[JsonPropertyName("logonDate")]
public required long LogonDateUnixTime { get; set; }
/// <summary>
/// 活动时间
/// </summary>
[Column("activedate")]
[Required]
[JsonPropertyName("activeDate")]
public required long ActiveDateUnixTime { get; set; }
/// <summary>
/// 过期时间
/// </summary>
[Column("expiredate")]
[Required]
[JsonPropertyName("expireDate")]
public required long ExpireDateUnixTime { get; set; }
/// <summary>
/// 过期秒数
/// </summary>
[Column("expiresecs")]
[Required]
public required int ExpireSeconds { get; set; }
/// <summary>
/// 验证码
/// </summary>
[Column("verifycode")]
public string? VerifyCode { get; set; }
/// <summary>
/// 客户端类型
/// </summary>
[Column("clientapp")]
public string? ClientApp { get; set; }
/// <summary>
/// 客户端设备 id
/// </summary>
[Column("deviceid")]
public string? DeviceId { get; set; }
/// <summary>
/// 客户端代理标识
/// </summary>
[Column("clientagent")]
public string? ClientAgent { get; set; }
/// <summary>
/// 登录时间
/// </summary>
[NotMapped]
[JsonIgnore]
public DateTimeOffset LogonDate => DateTimeOffset.FromUnixTimeMilliseconds(LogonDateUnixTime);
/// <summary>
/// 活动时间
/// </summary>
[NotMapped]
[JsonIgnore]
public DateTimeOffset ActiveDate => DateTimeOffset.FromUnixTimeMilliseconds(ActiveDateUnixTime);
/// <summary>
/// 过期时间
/// </summary>
[NotMapped]
[JsonIgnore]
public DateTimeOffset ExpireDate => DateTimeOffset.FromUnixTimeMilliseconds(ExpireDateUnixTime);
}