Rename projects to FileShare
This commit is contained in:
@@ -0,0 +1,79 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace FileShare_EFCore.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// API refresh token。只保存哈希,不保存明文 token。
|
||||
/// </summary>
|
||||
[Comment("API refresh token")]
|
||||
[Table("api-refresh-token")]
|
||||
public class ApiRefreshTokenEntity
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取或设置主键 ID(自增)。
|
||||
/// </summary>
|
||||
[Key]
|
||||
[Column("id")]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public long Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置关联的用户 ID。
|
||||
/// </summary>
|
||||
[Column("user-id")]
|
||||
public int UserId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置 Token 的 SHA256 哈希值,用于安全存储和查询。
|
||||
/// </summary>
|
||||
[Column("token-hash")]
|
||||
[MaxLength(128)]
|
||||
public string TokenHash { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置 Token 创建时间。
|
||||
/// </summary>
|
||||
[Column("created-at")]
|
||||
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置 Token 过期时间。
|
||||
/// </summary>
|
||||
[Column("expires-at")]
|
||||
public DateTime ExpiresAt { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置 Token 撤销时间,null 表示尚未撤销。
|
||||
/// </summary>
|
||||
[Column("revoked-at")]
|
||||
public DateTime? RevokedAt { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置替换此 Token 的新 Token 哈希值(轮换时设置)。
|
||||
/// </summary>
|
||||
[Column("replaced-by-token-hash")]
|
||||
[MaxLength(128)]
|
||||
public string? ReplacedByTokenHash { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置创建设备标识(如 User-Agent)。
|
||||
/// </summary>
|
||||
[Column("device")]
|
||||
[MaxLength(200)]
|
||||
public string? Device { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置创建时的客户端 IP 地址。
|
||||
/// </summary>
|
||||
[Column("ip-address")]
|
||||
[MaxLength(64)]
|
||||
public string? IpAddress { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取 Token 是否有效(未被撤销且未过期)。
|
||||
/// </summary>
|
||||
public bool IsActive => RevokedAt is null && ExpiresAt > DateTime.UtcNow;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace FileShare_EFCore.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// 扫描入库的可在线查看文件。
|
||||
/// </summary>
|
||||
[Comment("文件库文件记录")]
|
||||
[Table("managed-file-record")]
|
||||
public class ManagedFileRecord
|
||||
{
|
||||
/// <summary>主键 ID。</summary>
|
||||
[Key]
|
||||
[Column("id")]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public int Id { get; set; }
|
||||
|
||||
/// <summary>所属根目录 ID。</summary>
|
||||
[Column("library-root-id")]
|
||||
public int LibraryRootId { get; set; }
|
||||
|
||||
/// <summary>文件名。</summary>
|
||||
[Column("file-name")]
|
||||
[MaxLength(260)]
|
||||
public string FileName { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>相对根目录路径。</summary>
|
||||
[Column("relative-path")]
|
||||
[MaxLength(1024)]
|
||||
public string RelativePath { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>服务器本机绝对路径。</summary>
|
||||
[Column("absolute-path")]
|
||||
[MaxLength(2048)]
|
||||
public string AbsolutePath { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>扩展名,小写并包含点。</summary>
|
||||
[Column("extension")]
|
||||
[MaxLength(32)]
|
||||
public string Extension { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>文件大小,字节。</summary>
|
||||
[Column("size-bytes")]
|
||||
public long SizeBytes { get; set; }
|
||||
|
||||
/// <summary>文件最后修改时间 UTC。</summary>
|
||||
[Column("last-write-time-utc")]
|
||||
public DateTime LastWriteTimeUtc { get; set; }
|
||||
|
||||
/// <summary>媒体类型:text、video、audio。</summary>
|
||||
[Column("media-type")]
|
||||
[MaxLength(20)]
|
||||
public string MediaType { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>MIME 类型。</summary>
|
||||
[Column("content-type")]
|
||||
[MaxLength(100)]
|
||||
public string ContentType { get; set; } = "application/octet-stream";
|
||||
|
||||
/// <summary>文件是否仍存在。</summary>
|
||||
[Column("exists")]
|
||||
public bool Exists { get; set; } = true;
|
||||
|
||||
/// <summary>最近扫描时间。</summary>
|
||||
[Column("last-seen-at")]
|
||||
public DateTime LastSeenAt { get; set; } = DateTime.UtcNow;
|
||||
|
||||
/// <summary>创建时间。</summary>
|
||||
[Column("created-at")]
|
||||
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
|
||||
|
||||
/// <summary>更新时间。</summary>
|
||||
[Column("updated-at")]
|
||||
public DateTime UpdatedAt { get; set; } = DateTime.UtcNow;
|
||||
|
||||
/// <summary>所属根目录。</summary>
|
||||
public ManagedLibraryRoot? LibraryRoot { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace FileShare_EFCore.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// 管理端添加的文件库根目录或磁盘。
|
||||
/// </summary>
|
||||
[Comment("文件库根目录")]
|
||||
[Table("managed-library-root")]
|
||||
public class ManagedLibraryRoot
|
||||
{
|
||||
/// <summary>主键 ID。</summary>
|
||||
[Key]
|
||||
[Column("id")]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public int Id { get; set; }
|
||||
|
||||
/// <summary>服务器本机绝对路径。</summary>
|
||||
[Column("path")]
|
||||
[MaxLength(1024)]
|
||||
public string Path { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>显示名称。</summary>
|
||||
[Column("display-name")]
|
||||
[MaxLength(200)]
|
||||
public string DisplayName { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>是否启用扫描。</summary>
|
||||
[Column("is-enabled")]
|
||||
public bool IsEnabled { get; set; } = true;
|
||||
|
||||
/// <summary>目录最近一次扫描是否可用。</summary>
|
||||
[Column("is-available")]
|
||||
public bool IsAvailable { get; set; } = true;
|
||||
|
||||
/// <summary>扫描间隔分钟数。</summary>
|
||||
[Column("scan-interval-minutes")]
|
||||
public int ScanIntervalMinutes { get; set; } = 5;
|
||||
|
||||
/// <summary>最近扫描开始时间。</summary>
|
||||
[Column("last-scan-started-at")]
|
||||
public DateTime? LastScanStartedAt { get; set; }
|
||||
|
||||
/// <summary>最近扫描完成时间。</summary>
|
||||
[Column("last-scan-completed-at")]
|
||||
public DateTime? LastScanCompletedAt { get; set; }
|
||||
|
||||
/// <summary>最近扫描错误。</summary>
|
||||
[Column("last-scan-error")]
|
||||
[MaxLength(2000)]
|
||||
public string? LastScanError { get; set; }
|
||||
|
||||
/// <summary>创建时间。</summary>
|
||||
[Column("created-at")]
|
||||
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
|
||||
|
||||
/// <summary>更新时间。</summary>
|
||||
[Column("updated-at")]
|
||||
public DateTime UpdatedAt { get; set; } = DateTime.UtcNow;
|
||||
|
||||
/// <summary>文件记录。</summary>
|
||||
public List<ManagedFileRecord> Files { get; set; } = new();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace FileShare_EFCore.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// 用户实体 —— 演示数据库 CRUD 操作。
|
||||
/// </summary>
|
||||
[Comment("用户实体,演示数据库 CRUD 操作")]
|
||||
[Table("user")]
|
||||
public class UserEntity
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取或设置用户主键 ID(自增)。
|
||||
/// </summary>
|
||||
[Key]
|
||||
[Comment("用户主键")]
|
||||
[Column("id")]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public int Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置用户名称。
|
||||
/// </summary>
|
||||
[Comment("用户名称")]
|
||||
[Column("name")]
|
||||
[MaxLength(100)]
|
||||
public string? Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置用户密码哈希值。
|
||||
/// </summary>
|
||||
[Comment("密码哈希值")]
|
||||
[Column("password-hash")]
|
||||
[MaxLength(200)]
|
||||
public string? PasswordHash { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置用户邮箱。
|
||||
/// </summary>
|
||||
[Comment("用户邮箱")]
|
||||
[Column("email")]
|
||||
[MaxLength(200)]
|
||||
public string? Email { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置用户电话号码。
|
||||
/// </summary>
|
||||
[Comment("电话号码")]
|
||||
[Column("phone-number")]
|
||||
[MaxLength(50)]
|
||||
public string? PhoneNumber { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置用户创建时间。
|
||||
/// </summary>
|
||||
[Comment("创建时间")]
|
||||
[Column("created-at")]
|
||||
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置用户最后更新时间。
|
||||
/// </summary>
|
||||
[Comment("更新时间")]
|
||||
[Column("updated-at")]
|
||||
public DateTime UpdatedAt { get; set; } = DateTime.UtcNow;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
namespace FileShare_EFCore.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// 天气预报数据模型(内存/DTO 用,非数据库实体)。
|
||||
/// </summary>
|
||||
public class WeatherForecast
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取或设置预报日期。
|
||||
/// </summary>
|
||||
public DateOnly Date { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置摄氏温度。
|
||||
/// </summary>
|
||||
public int TemperatureC { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取华氏温度(根据摄氏温度自动计算)。
|
||||
/// </summary>
|
||||
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置天气摘要。
|
||||
/// </summary>
|
||||
public string? Summary { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace FileShare_EFCore.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// 天气预报数据实体。
|
||||
/// </summary>
|
||||
[Comment("天气预报数据实体")]
|
||||
[Table("weather-forecast")]
|
||||
public class WeatherForecastEntity
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取或设置天气预报主键 ID(自增)。
|
||||
/// </summary>
|
||||
[Key]
|
||||
[Comment("天气预报主键")]
|
||||
[Column("id")]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public int Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置预报日期。
|
||||
/// </summary>
|
||||
[Comment("预报日期")]
|
||||
[Column("date")]
|
||||
public DateOnly Date { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置摄氏温度。
|
||||
/// </summary>
|
||||
[Comment("摄氏温度")]
|
||||
[Column("temperature-c")]
|
||||
public int TemperatureC { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置天气摘要。
|
||||
/// </summary>
|
||||
[Comment("天气摘要")]
|
||||
[Column("summary")]
|
||||
[MaxLength(200)]
|
||||
public string? Summary { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置记录创建时间。
|
||||
/// </summary>
|
||||
[Comment("创建时间")]
|
||||
[Column("created-at")]
|
||||
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置记录最后更新时间。
|
||||
/// </summary>
|
||||
[Comment("更新时间")]
|
||||
[Column("updated-at")]
|
||||
public DateTime UpdatedAt { get; set; } = DateTime.UtcNow;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user