初始化

This commit is contained in:
2025-10-16 09:56:36 +08:00
commit de704db577
272 changed files with 37331 additions and 0 deletions

View File

@@ -0,0 +1,63 @@
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!;
}
}

View File

@@ -0,0 +1,39 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace FutureMailAPI.Models
{
public class ReceivedMail
{
[Key]
public int Id { get; set; }
[Required]
public int SentMailId { get; set; }
[Required]
public int RecipientId { get; set; }
// 接收时间
public DateTime ReceivedAt { get; set; } = DateTime.UtcNow;
// 是否已读
public bool IsRead { get; set; } = false;
// 阅读时间
public DateTime? ReadAt { get; set; }
// 是否已回复
public bool IsReplied { get; set; } = false;
// 回复邮件ID
public int? ReplyMailId { get; set; }
// 导航属性
[ForeignKey("SentMailId")]
public virtual SentMail SentMail { get; set; } = null!;
[ForeignKey("RecipientId")]
public virtual User Recipient { get; set; } = null!;
}
}

View File

@@ -0,0 +1,65 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace FutureMailAPI.Models
{
public class SentMail
{
[Key]
public int Id { get; set; }
[Required]
[MaxLength(200)]
public string Title { get; set; } = string.Empty;
[Required]
public string Content { get; set; } = string.Empty;
[Required]
public int SenderId { get; set; }
// 收件人类型: 0-自己, 1-指定用户, 2-公开时间胶囊
[Required]
public int RecipientType { get; set; }
// 如果是指定用户存储用户ID
public int? RecipientId { get; set; }
// 发送时间
public DateTime SentAt { get; set; } = DateTime.UtcNow;
// 投递时间
[Required]
public DateTime DeliveryTime { get; set; }
// 邮件状态: 0-草稿, 1-已发送(待投递), 2-投递中, 3-已送达
[Required]
public int Status { get; set; } = 0;
// 触发条件类型: 0-时间, 1-地点, 2-事件
[Required]
public int TriggerType { get; set; } = 0;
// 触发条件详情(JSON格式存储)
public string? TriggerDetails { get; set; }
// 附件路径(JSON数组格式)
public string? Attachments { get; set; }
// 是否加密
public bool IsEncrypted { get; set; } = false;
// 加密密钥(如果使用端到端加密)
public string? EncryptionKey { get; set; }
// 邮件主题/胶囊皮肤
[MaxLength(50)]
public string? Theme { get; set; }
// 导航属性
[ForeignKey("SenderId")]
public virtual User Sender { get; set; } = null!;
public virtual User? Recipient { get; set; }
}
}

View File

@@ -0,0 +1,53 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace FutureMailAPI.Models
{
public class TimeCapsule
{
[Key]
public int Id { get; set; }
[Required]
public int UserId { get; set; }
[Required]
public int SentMailId { get; set; }
// 胶囊位置信息(X, Y, Z坐标)
public double PositionX { get; set; }
public double PositionY { get; set; }
public double PositionZ { get; set; }
// 胶囊大小
public double Size { get; set; } = 1.0;
// 胶囊颜色
[MaxLength(20)]
public string? Color { get; set; }
// 胶囊透明度
public double Opacity { get; set; } = 1.0;
// 胶囊旋转角度
public double Rotation { get; set; } = 0;
// 胶囊状态: 0-未激活, 1-漂浮中, 2-即将到达, 3-已开启
[Required]
public int Status { get; set; } = 0;
// 胶囊类型: 0-普通, 1-特殊, 2-限时
[Required]
public int Type { get; set; } = 0;
// 创建时间
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
// 导航属性
[ForeignKey("UserId")]
public virtual User User { get; set; } = null!;
[ForeignKey("SentMailId")]
public virtual SentMail SentMail { get; set; } = null!;
}
}

View File

@@ -0,0 +1,50 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace FutureMailAPI.Models
{
public class User
{
[Key]
public int Id { get; set; }
[Required]
[MaxLength(100)]
public string Username { get; set; } = string.Empty;
[Required]
[MaxLength(255)]
public string Email { get; set; } = string.Empty;
[Required]
[MaxLength(255)]
public string PasswordHash { get; set; } = string.Empty;
[Required]
[MaxLength(255)]
public string Salt { get; set; } = string.Empty;
[MaxLength(100)]
public string? Nickname { get; set; }
[MaxLength(500)]
public string? Avatar { get; set; }
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
public DateTime? LastLoginAt { get; set; }
public bool IsActive { get; set; } = true;
[MaxLength(20)]
public string? PreferredScene { get; set; } = "SPACE";
[MaxLength(50)]
public string? PreferredBackground { get; set; } = "default";
// 导航属性
public virtual ICollection<SentMail> SentMails { get; set; } = new List<SentMail>();
public virtual ICollection<ReceivedMail> ReceivedMails { get; set; } = new List<ReceivedMail>();
public virtual ICollection<TimeCapsule> TimeCapsules { get; set; } = new List<TimeCapsule>();
}
}