From 4f3eecabc469413606e4a0717849c7e28849697f Mon Sep 17 00:00:00 2001 From: Seany <17074267@qq.com> Date: Wed, 3 Dec 2025 12:25:20 +0800 Subject: [PATCH] add refresh token entity --- Atomx.Admin/Atomx.Admin/Program.cs | 3 ++ Atomx.Common/Entities/RefreshToken.cs | 57 +++++++++++++++++++++++++++ Atomx.Data/DataContext.cs | 5 +++ 3 files changed, 65 insertions(+) create mode 100644 Atomx.Common/Entities/RefreshToken.cs diff --git a/Atomx.Admin/Atomx.Admin/Program.cs b/Atomx.Admin/Atomx.Admin/Program.cs index ec6753a..1555ec9 100644 --- a/Atomx.Admin/Atomx.Admin/Program.cs +++ b/Atomx.Admin/Atomx.Admin/Program.cs @@ -27,6 +27,9 @@ var builder = WebApplication.CreateBuilder(args); Log.Logger = new LoggerConfiguration() .ReadFrom.Configuration(builder.Configuration) .Enrich.FromLogContext() + .Enrich.WithProperty("Application", "Atomx.Admin") + .Enrich.WithProperty("Environment", builder.Environment.EnvironmentName) + .WriteTo.Console(outputTemplate: "[{Timestamp:HH:mm:ss} {Level:u3}] {Message:lj}{NewLine}{Exception}") .CreateLogger(); // Add services to the container. diff --git a/Atomx.Common/Entities/RefreshToken.cs b/Atomx.Common/Entities/RefreshToken.cs new file mode 100644 index 0000000..a13f506 --- /dev/null +++ b/Atomx.Common/Entities/RefreshToken.cs @@ -0,0 +1,57 @@ +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +namespace Atomx.Common.Entities +{ + /// + /// 刷新TOKEN + /// + [Table("RefreshTokens")] + public class RefreshToken + { + /// + /// 数据ID + /// + [DatabaseGenerated(DatabaseGeneratedOption.None)] + [Key] + public string Id { get; set; } = Guid.NewGuid().ToString(); + + /// + /// 用户ID + /// + public long UserId { get; set; } + + /// + /// Token 信息 + /// + [Column(TypeName = "varchar(500)")] + public string Token { get; set; } = string.Empty; + + /// + /// 发布时间 + /// + public DateTime IssuedTime { get; set; } = DateTime.UtcNow; + + /// + /// 到期时间 + /// + public DateTime ExpiresTime { get; set; } + + /// + /// 是否回收 + /// + public bool IsRevoked { get; set; } + + /// + /// 用户IP + /// + [Column(TypeName = "varchar(50)")] + public string Ip { get; set; } = string.Empty; + + /// + /// 用户系统代理信息 + /// + [Column(TypeName = "varchar(500)")] + public string UserAgent { get; set; } = string.Empty; + } +} diff --git a/Atomx.Data/DataContext.cs b/Atomx.Data/DataContext.cs index 1bc5fe2..5b31b7d 100644 --- a/Atomx.Data/DataContext.cs +++ b/Atomx.Data/DataContext.cs @@ -132,6 +132,11 @@ namespace Atomx.Data /// public DbSet SpecificationAttributeOptions { get; set; } + /// + /// 刷新Tokens + /// + public DbSet RefreshTokens { get; set; } + /// /// 用户角色 ///