修改接口
This commit is contained in:
38
FutureMailAPI/Models/OAuthClient.cs
Normal file
38
FutureMailAPI/Models/OAuthClient.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace FutureMailAPI.Models
|
||||
{
|
||||
public class OAuthClient
|
||||
{
|
||||
[Key]
|
||||
public int Id { get; set; }
|
||||
|
||||
[Required]
|
||||
[MaxLength(100)]
|
||||
public string ClientId { get; set; } = string.Empty;
|
||||
|
||||
[Required]
|
||||
[MaxLength(255)]
|
||||
public string ClientSecret { get; set; } = string.Empty;
|
||||
|
||||
[Required]
|
||||
[MaxLength(100)]
|
||||
public string Name { get; set; } = string.Empty;
|
||||
|
||||
[Required]
|
||||
public string RedirectUris { get; set; } = string.Empty;
|
||||
|
||||
[Required]
|
||||
public string Scopes { get; set; } = string.Empty;
|
||||
|
||||
public bool IsActive { get; set; } = true;
|
||||
|
||||
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
|
||||
|
||||
public DateTime UpdatedAt { get; set; } = DateTime.UtcNow;
|
||||
|
||||
// 导航属性
|
||||
public virtual ICollection<OAuthToken> Tokens { get; set; } = new List<OAuthToken>();
|
||||
}
|
||||
}
|
||||
@@ -1,63 +0,0 @@
|
||||
namespace FutureMailAPI.Models
|
||||
{
|
||||
public class OAuthClient
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string ClientId { get; set; } = string.Empty;
|
||||
public string ClientSecret { get; set; } = string.Empty;
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public string RedirectUris { get; set; } = string.Empty; // JSON array
|
||||
public string Scopes { get; set; } = string.Empty; // JSON array
|
||||
public bool IsActive { get; set; } = true;
|
||||
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
|
||||
public DateTime UpdatedAt { get; set; } = DateTime.UtcNow;
|
||||
}
|
||||
|
||||
public class OAuthAuthorizationCode
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Code { get; set; } = string.Empty;
|
||||
public int ClientId { get; set; }
|
||||
public int UserId { get; set; }
|
||||
public string RedirectUri { get; set; } = string.Empty;
|
||||
public string Scopes { get; set; } = string.Empty;
|
||||
public bool IsUsed { get; set; } = false;
|
||||
public DateTime ExpiresAt { get; set; }
|
||||
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
|
||||
|
||||
// Navigation properties
|
||||
public virtual OAuthClient Client { get; set; } = null!;
|
||||
public virtual User User { get; set; } = null!;
|
||||
}
|
||||
|
||||
public class OAuthRefreshToken
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Token { get; set; } = string.Empty;
|
||||
public int ClientId { get; set; }
|
||||
public int UserId { get; set; }
|
||||
public bool IsUsed { get; set; } = false;
|
||||
public DateTime ExpiresAt { get; set; }
|
||||
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
|
||||
|
||||
// Navigation properties
|
||||
public virtual OAuthClient Client { get; set; } = null!;
|
||||
public virtual User User { get; set; } = null!;
|
||||
}
|
||||
|
||||
public class OAuthAccessToken
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Token { get; set; } = string.Empty;
|
||||
public int ClientId { get; set; }
|
||||
public int UserId { get; set; }
|
||||
public string Scopes { get; set; } = string.Empty;
|
||||
public bool IsRevoked { get; set; } = false;
|
||||
public DateTime ExpiresAt { get; set; }
|
||||
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
|
||||
|
||||
// Navigation properties
|
||||
public virtual OAuthClient Client { get; set; } = null!;
|
||||
public virtual User User { get; set; } = null!;
|
||||
}
|
||||
}
|
||||
44
FutureMailAPI/Models/OAuthToken.cs
Normal file
44
FutureMailAPI/Models/OAuthToken.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
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!;
|
||||
}
|
||||
}
|
||||
@@ -42,6 +42,12 @@ namespace FutureMailAPI.Models
|
||||
[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>();
|
||||
|
||||
Reference in New Issue
Block a user