feat: 新增文件库功能,支持局域网文件浏览与媒体播放
后端: - 新增 ManagedLibraryRoot / ManagedFileRecord 数据模型及 SQLite 迁移 - 新增文件库服务、端点服务及定时扫描后台任务 - 新增 REST API: drives、directories、roots CRUD、files 分页搜索、文本预览 - 新增文件流端点支持视频/音频流式传输 - 数据库切换为 SQLite,Kestrel 绑定 0.0.0.0 支持局域网访问 前端: - 管理端:磁盘浏览、目录选择、根目录添加/启用/删除/扫描 - 客户端:根目录选择、文件搜索/筛选/分页、音视频播放、文本预览 - 全新响应式 UI(桌面+移动端),CSS 变量设计系统 - HTTP 客户端支持 Vite 开发代理与生产同源自动切换 - 移除 HTTPS 强制重定向以提升移动端视频流兼容性
This commit is contained in:
@@ -19,6 +19,12 @@ namespace Avalonia_EFCore.Database
|
||||
/// <summary>API refresh token 数据</summary>
|
||||
public DbSet<ApiRefreshTokenEntity> ApiRefreshTokens => Set<ApiRefreshTokenEntity>();
|
||||
|
||||
/// <summary>文件库根目录数据</summary>
|
||||
public DbSet<ManagedLibraryRoot> ManagedLibraryRoots => Set<ManagedLibraryRoot>();
|
||||
|
||||
/// <summary>文件库文件记录数据</summary>
|
||||
public DbSet<ManagedFileRecord> ManagedFileRecords => Set<ManagedFileRecord>();
|
||||
|
||||
/// <summary>
|
||||
/// 配置实体映射,包括主键、索引和属性约束。
|
||||
/// </summary>
|
||||
@@ -45,6 +51,34 @@ namespace Avalonia_EFCore.Database
|
||||
entity.HasIndex(e => e.TokenHash).IsUnique().HasDatabaseName("idx-api-refresh-token-hash");
|
||||
entity.HasIndex(e => e.UserId).HasDatabaseName("idx-api-refresh-token-user-id");
|
||||
});
|
||||
|
||||
modelBuilder.Entity<ManagedLibraryRoot>(entity =>
|
||||
{
|
||||
entity.HasKey(e => e.Id).HasName("pk-managed-library-root");
|
||||
entity.HasIndex(e => e.Path).IsUnique().HasDatabaseName("idx-managed-library-root-path");
|
||||
entity.Property(e => e.Path).HasMaxLength(1024);
|
||||
entity.Property(e => e.DisplayName).HasMaxLength(200);
|
||||
entity.Property(e => e.LastScanError).HasMaxLength(2000);
|
||||
entity.Property(e => e.IsAvailable).HasDefaultValue(true);
|
||||
});
|
||||
|
||||
modelBuilder.Entity<ManagedFileRecord>(entity =>
|
||||
{
|
||||
entity.HasKey(e => e.Id).HasName("pk-managed-file-record");
|
||||
entity.HasIndex(e => e.LibraryRootId).HasDatabaseName("idx-managed-file-record-root-id");
|
||||
entity.HasIndex(e => e.AbsolutePath).IsUnique().HasDatabaseName("idx-managed-file-record-absolute-path");
|
||||
entity.HasIndex(e => new { e.MediaType, e.Exists }).HasDatabaseName("idx-managed-file-record-media-type-exists");
|
||||
entity.Property(e => e.FileName).HasMaxLength(260);
|
||||
entity.Property(e => e.RelativePath).HasMaxLength(1024);
|
||||
entity.Property(e => e.AbsolutePath).HasMaxLength(2048);
|
||||
entity.Property(e => e.Extension).HasMaxLength(32);
|
||||
entity.Property(e => e.MediaType).HasMaxLength(20);
|
||||
entity.Property(e => e.ContentType).HasMaxLength(100);
|
||||
entity.HasOne(e => e.LibraryRoot)
|
||||
.WithMany(e => e.Files)
|
||||
.HasForeignKey(e => e.LibraryRootId)
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+352
@@ -0,0 +1,352 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using Avalonia_EFCore.Database;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Avalonia_EFCore.Migrations.SQLite
|
||||
{
|
||||
[DbContext(typeof(SqliteAppDataContext))]
|
||||
[Migration("20260521080213_AddFileLibrary")]
|
||||
partial class AddFileLibrary
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder.HasAnnotation("ProductVersion", "10.0.7");
|
||||
|
||||
modelBuilder.Entity("Avalonia_EFCore.Models.ApiRefreshTokenEntity", b =>
|
||||
{
|
||||
b.Property<long>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER")
|
||||
.HasColumnName("id");
|
||||
|
||||
b.Property<DateTime>("CreatedAt")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnName("created-at");
|
||||
|
||||
b.Property<string>("Device")
|
||||
.HasMaxLength(200)
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnName("device");
|
||||
|
||||
b.Property<DateTime>("ExpiresAt")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnName("expires-at");
|
||||
|
||||
b.Property<string>("IpAddress")
|
||||
.HasMaxLength(64)
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnName("ip-address");
|
||||
|
||||
b.Property<string>("ReplacedByTokenHash")
|
||||
.HasMaxLength(128)
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnName("replaced-by-token-hash");
|
||||
|
||||
b.Property<DateTime?>("RevokedAt")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnName("revoked-at");
|
||||
|
||||
b.Property<string>("TokenHash")
|
||||
.IsRequired()
|
||||
.HasMaxLength(128)
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnName("token-hash");
|
||||
|
||||
b.Property<int>("UserId")
|
||||
.HasColumnType("INTEGER")
|
||||
.HasColumnName("user-id");
|
||||
|
||||
b.HasKey("Id")
|
||||
.HasName("pk-api-refresh-token");
|
||||
|
||||
b.HasIndex("TokenHash")
|
||||
.IsUnique()
|
||||
.HasDatabaseName("idx-api-refresh-token-hash");
|
||||
|
||||
b.HasIndex("UserId")
|
||||
.HasDatabaseName("idx-api-refresh-token-user-id");
|
||||
|
||||
b.ToTable("api-refresh-token", t =>
|
||||
{
|
||||
t.HasComment("API refresh token");
|
||||
});
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Avalonia_EFCore.Models.ManagedFileRecord", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER")
|
||||
.HasColumnName("id");
|
||||
|
||||
b.Property<string>("AbsolutePath")
|
||||
.IsRequired()
|
||||
.HasMaxLength(2048)
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnName("absolute-path");
|
||||
|
||||
b.Property<string>("ContentType")
|
||||
.IsRequired()
|
||||
.HasMaxLength(100)
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnName("content-type");
|
||||
|
||||
b.Property<DateTime>("CreatedAt")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnName("created-at");
|
||||
|
||||
b.Property<bool>("Exists")
|
||||
.HasColumnType("INTEGER")
|
||||
.HasColumnName("exists");
|
||||
|
||||
b.Property<string>("Extension")
|
||||
.IsRequired()
|
||||
.HasMaxLength(32)
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnName("extension");
|
||||
|
||||
b.Property<string>("FileName")
|
||||
.IsRequired()
|
||||
.HasMaxLength(260)
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnName("file-name");
|
||||
|
||||
b.Property<DateTime>("LastSeenAt")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnName("last-seen-at");
|
||||
|
||||
b.Property<DateTime>("LastWriteTimeUtc")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnName("last-write-time-utc");
|
||||
|
||||
b.Property<int>("LibraryRootId")
|
||||
.HasColumnType("INTEGER")
|
||||
.HasColumnName("library-root-id");
|
||||
|
||||
b.Property<string>("MediaType")
|
||||
.IsRequired()
|
||||
.HasMaxLength(20)
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnName("media-type");
|
||||
|
||||
b.Property<string>("RelativePath")
|
||||
.IsRequired()
|
||||
.HasMaxLength(1024)
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnName("relative-path");
|
||||
|
||||
b.Property<long>("SizeBytes")
|
||||
.HasColumnType("INTEGER")
|
||||
.HasColumnName("size-bytes");
|
||||
|
||||
b.Property<DateTime>("UpdatedAt")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnName("updated-at");
|
||||
|
||||
b.HasKey("Id")
|
||||
.HasName("pk-managed-file-record");
|
||||
|
||||
b.HasIndex("AbsolutePath")
|
||||
.IsUnique()
|
||||
.HasDatabaseName("idx-managed-file-record-absolute-path");
|
||||
|
||||
b.HasIndex("LibraryRootId")
|
||||
.HasDatabaseName("idx-managed-file-record-root-id");
|
||||
|
||||
b.HasIndex("MediaType", "Exists")
|
||||
.HasDatabaseName("idx-managed-file-record-media-type-exists");
|
||||
|
||||
b.ToTable("managed-file-record", t =>
|
||||
{
|
||||
t.HasComment("文件库文件记录");
|
||||
});
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Avalonia_EFCore.Models.ManagedLibraryRoot", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER")
|
||||
.HasColumnName("id");
|
||||
|
||||
b.Property<DateTime>("CreatedAt")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnName("created-at");
|
||||
|
||||
b.Property<string>("DisplayName")
|
||||
.IsRequired()
|
||||
.HasMaxLength(200)
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnName("display-name");
|
||||
|
||||
b.Property<bool>("IsAvailable")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER")
|
||||
.HasDefaultValue(true)
|
||||
.HasColumnName("is-available");
|
||||
|
||||
b.Property<bool>("IsEnabled")
|
||||
.HasColumnType("INTEGER")
|
||||
.HasColumnName("is-enabled");
|
||||
|
||||
b.Property<DateTime?>("LastScanCompletedAt")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnName("last-scan-completed-at");
|
||||
|
||||
b.Property<string>("LastScanError")
|
||||
.HasMaxLength(2000)
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnName("last-scan-error");
|
||||
|
||||
b.Property<DateTime?>("LastScanStartedAt")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnName("last-scan-started-at");
|
||||
|
||||
b.Property<string>("Path")
|
||||
.IsRequired()
|
||||
.HasMaxLength(1024)
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnName("path");
|
||||
|
||||
b.Property<int>("ScanIntervalMinutes")
|
||||
.HasColumnType("INTEGER")
|
||||
.HasColumnName("scan-interval-minutes");
|
||||
|
||||
b.Property<DateTime>("UpdatedAt")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnName("updated-at");
|
||||
|
||||
b.HasKey("Id")
|
||||
.HasName("pk-managed-library-root");
|
||||
|
||||
b.HasIndex("Path")
|
||||
.IsUnique()
|
||||
.HasDatabaseName("idx-managed-library-root-path");
|
||||
|
||||
b.ToTable("managed-library-root", t =>
|
||||
{
|
||||
t.HasComment("文件库根目录");
|
||||
});
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Avalonia_EFCore.Models.UserEntity", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER")
|
||||
.HasColumnName("id")
|
||||
.HasComment("用户主键");
|
||||
|
||||
b.Property<DateTime>("CreatedAt")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnName("created-at")
|
||||
.HasComment("创建时间");
|
||||
|
||||
b.Property<string>("Email")
|
||||
.HasMaxLength(200)
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnName("email")
|
||||
.HasComment("用户邮箱");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.HasMaxLength(100)
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnName("name")
|
||||
.HasComment("用户名称");
|
||||
|
||||
b.Property<string>("PasswordHash")
|
||||
.HasMaxLength(200)
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnName("password-hash")
|
||||
.HasComment("密码哈希值");
|
||||
|
||||
b.Property<string>("PhoneNumber")
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnName("phone-number")
|
||||
.HasComment("电话号码");
|
||||
|
||||
b.Property<DateTime>("UpdatedAt")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnName("updated-at")
|
||||
.HasComment("更新时间");
|
||||
|
||||
b.HasKey("Id")
|
||||
.HasName("pk-user");
|
||||
|
||||
b.ToTable("user", t =>
|
||||
{
|
||||
t.HasComment("用户实体,演示数据库 CRUD 操作");
|
||||
});
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Avalonia_EFCore.Models.WeatherForecastEntity", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER")
|
||||
.HasColumnName("id")
|
||||
.HasComment("天气预报主键");
|
||||
|
||||
b.Property<DateTime>("CreatedAt")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnName("created-at")
|
||||
.HasComment("创建时间");
|
||||
|
||||
b.Property<DateOnly>("Date")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnName("date")
|
||||
.HasComment("预报日期");
|
||||
|
||||
b.Property<string>("Summary")
|
||||
.HasMaxLength(200)
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnName("summary")
|
||||
.HasComment("天气摘要");
|
||||
|
||||
b.Property<int>("TemperatureC")
|
||||
.HasColumnType("INTEGER")
|
||||
.HasColumnName("temperature-c")
|
||||
.HasComment("摄氏温度");
|
||||
|
||||
b.Property<DateTime>("UpdatedAt")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnName("updated-at")
|
||||
.HasComment("更新时间");
|
||||
|
||||
b.HasKey("Id")
|
||||
.HasName("pk-weather-forecast");
|
||||
|
||||
b.ToTable("weather-forecast", t =>
|
||||
{
|
||||
t.HasComment("天气预报数据实体");
|
||||
});
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Avalonia_EFCore.Models.ManagedFileRecord", b =>
|
||||
{
|
||||
b.HasOne("Avalonia_EFCore.Models.ManagedLibraryRoot", "LibraryRoot")
|
||||
.WithMany("Files")
|
||||
.HasForeignKey("LibraryRootId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("LibraryRoot");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Avalonia_EFCore.Models.ManagedLibraryRoot", b =>
|
||||
{
|
||||
b.Navigation("Files");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Avalonia_EFCore.Migrations.SQLite
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class AddFileLibrary : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "managed-library-root",
|
||||
columns: table => new
|
||||
{
|
||||
id = table.Column<int>(type: "INTEGER", nullable: false)
|
||||
.Annotation("Sqlite:Autoincrement", true),
|
||||
path = table.Column<string>(type: "TEXT", maxLength: 1024, nullable: false),
|
||||
displayname = table.Column<string>(name: "display-name", type: "TEXT", maxLength: 200, nullable: false),
|
||||
isenabled = table.Column<bool>(name: "is-enabled", type: "INTEGER", nullable: false),
|
||||
isavailable = table.Column<bool>(name: "is-available", type: "INTEGER", nullable: false, defaultValue: true),
|
||||
scanintervalminutes = table.Column<int>(name: "scan-interval-minutes", type: "INTEGER", nullable: false),
|
||||
lastscanstartedat = table.Column<DateTime>(name: "last-scan-started-at", type: "TEXT", nullable: true),
|
||||
lastscancompletedat = table.Column<DateTime>(name: "last-scan-completed-at", type: "TEXT", nullable: true),
|
||||
lastscanerror = table.Column<string>(name: "last-scan-error", type: "TEXT", maxLength: 2000, nullable: true),
|
||||
createdat = table.Column<DateTime>(name: "created-at", type: "TEXT", nullable: false),
|
||||
updatedat = table.Column<DateTime>(name: "updated-at", type: "TEXT", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("pk-managed-library-root", x => x.id);
|
||||
},
|
||||
comment: "文件库根目录");
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "managed-file-record",
|
||||
columns: table => new
|
||||
{
|
||||
id = table.Column<int>(type: "INTEGER", nullable: false)
|
||||
.Annotation("Sqlite:Autoincrement", true),
|
||||
libraryrootid = table.Column<int>(name: "library-root-id", type: "INTEGER", nullable: false),
|
||||
filename = table.Column<string>(name: "file-name", type: "TEXT", maxLength: 260, nullable: false),
|
||||
relativepath = table.Column<string>(name: "relative-path", type: "TEXT", maxLength: 1024, nullable: false),
|
||||
absolutepath = table.Column<string>(name: "absolute-path", type: "TEXT", maxLength: 2048, nullable: false),
|
||||
extension = table.Column<string>(type: "TEXT", maxLength: 32, nullable: false),
|
||||
sizebytes = table.Column<long>(name: "size-bytes", type: "INTEGER", nullable: false),
|
||||
lastwritetimeutc = table.Column<DateTime>(name: "last-write-time-utc", type: "TEXT", nullable: false),
|
||||
mediatype = table.Column<string>(name: "media-type", type: "TEXT", maxLength: 20, nullable: false),
|
||||
contenttype = table.Column<string>(name: "content-type", type: "TEXT", maxLength: 100, nullable: false),
|
||||
exists = table.Column<bool>(type: "INTEGER", nullable: false),
|
||||
lastseenat = table.Column<DateTime>(name: "last-seen-at", type: "TEXT", nullable: false),
|
||||
createdat = table.Column<DateTime>(name: "created-at", type: "TEXT", nullable: false),
|
||||
updatedat = table.Column<DateTime>(name: "updated-at", type: "TEXT", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("pk-managed-file-record", x => x.id);
|
||||
table.ForeignKey(
|
||||
name: "FK_managed-file-record_managed-library-root_library-root-id",
|
||||
column: x => x.libraryrootid,
|
||||
principalTable: "managed-library-root",
|
||||
principalColumn: "id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
},
|
||||
comment: "文件库文件记录");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "idx-managed-file-record-absolute-path",
|
||||
table: "managed-file-record",
|
||||
column: "absolute-path",
|
||||
unique: true);
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "idx-managed-file-record-media-type-exists",
|
||||
table: "managed-file-record",
|
||||
columns: new[] { "media-type", "exists" });
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "idx-managed-file-record-root-id",
|
||||
table: "managed-file-record",
|
||||
column: "library-root-id");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "idx-managed-library-root-path",
|
||||
table: "managed-library-root",
|
||||
column: "path",
|
||||
unique: true);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "managed-file-record");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "managed-library-root");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -77,6 +77,163 @@ namespace Avalonia_EFCore.Migrations.SQLite
|
||||
});
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Avalonia_EFCore.Models.ManagedFileRecord", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER")
|
||||
.HasColumnName("id");
|
||||
|
||||
b.Property<string>("AbsolutePath")
|
||||
.IsRequired()
|
||||
.HasMaxLength(2048)
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnName("absolute-path");
|
||||
|
||||
b.Property<string>("ContentType")
|
||||
.IsRequired()
|
||||
.HasMaxLength(100)
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnName("content-type");
|
||||
|
||||
b.Property<DateTime>("CreatedAt")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnName("created-at");
|
||||
|
||||
b.Property<bool>("Exists")
|
||||
.HasColumnType("INTEGER")
|
||||
.HasColumnName("exists");
|
||||
|
||||
b.Property<string>("Extension")
|
||||
.IsRequired()
|
||||
.HasMaxLength(32)
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnName("extension");
|
||||
|
||||
b.Property<string>("FileName")
|
||||
.IsRequired()
|
||||
.HasMaxLength(260)
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnName("file-name");
|
||||
|
||||
b.Property<DateTime>("LastSeenAt")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnName("last-seen-at");
|
||||
|
||||
b.Property<DateTime>("LastWriteTimeUtc")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnName("last-write-time-utc");
|
||||
|
||||
b.Property<int>("LibraryRootId")
|
||||
.HasColumnType("INTEGER")
|
||||
.HasColumnName("library-root-id");
|
||||
|
||||
b.Property<string>("MediaType")
|
||||
.IsRequired()
|
||||
.HasMaxLength(20)
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnName("media-type");
|
||||
|
||||
b.Property<string>("RelativePath")
|
||||
.IsRequired()
|
||||
.HasMaxLength(1024)
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnName("relative-path");
|
||||
|
||||
b.Property<long>("SizeBytes")
|
||||
.HasColumnType("INTEGER")
|
||||
.HasColumnName("size-bytes");
|
||||
|
||||
b.Property<DateTime>("UpdatedAt")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnName("updated-at");
|
||||
|
||||
b.HasKey("Id")
|
||||
.HasName("pk-managed-file-record");
|
||||
|
||||
b.HasIndex("AbsolutePath")
|
||||
.IsUnique()
|
||||
.HasDatabaseName("idx-managed-file-record-absolute-path");
|
||||
|
||||
b.HasIndex("LibraryRootId")
|
||||
.HasDatabaseName("idx-managed-file-record-root-id");
|
||||
|
||||
b.HasIndex("MediaType", "Exists")
|
||||
.HasDatabaseName("idx-managed-file-record-media-type-exists");
|
||||
|
||||
b.ToTable("managed-file-record", t =>
|
||||
{
|
||||
t.HasComment("文件库文件记录");
|
||||
});
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Avalonia_EFCore.Models.ManagedLibraryRoot", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER")
|
||||
.HasColumnName("id");
|
||||
|
||||
b.Property<DateTime>("CreatedAt")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnName("created-at");
|
||||
|
||||
b.Property<string>("DisplayName")
|
||||
.IsRequired()
|
||||
.HasMaxLength(200)
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnName("display-name");
|
||||
|
||||
b.Property<bool>("IsAvailable")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER")
|
||||
.HasDefaultValue(true)
|
||||
.HasColumnName("is-available");
|
||||
|
||||
b.Property<bool>("IsEnabled")
|
||||
.HasColumnType("INTEGER")
|
||||
.HasColumnName("is-enabled");
|
||||
|
||||
b.Property<DateTime?>("LastScanCompletedAt")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnName("last-scan-completed-at");
|
||||
|
||||
b.Property<string>("LastScanError")
|
||||
.HasMaxLength(2000)
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnName("last-scan-error");
|
||||
|
||||
b.Property<DateTime?>("LastScanStartedAt")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnName("last-scan-started-at");
|
||||
|
||||
b.Property<string>("Path")
|
||||
.IsRequired()
|
||||
.HasMaxLength(1024)
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnName("path");
|
||||
|
||||
b.Property<int>("ScanIntervalMinutes")
|
||||
.HasColumnType("INTEGER")
|
||||
.HasColumnName("scan-interval-minutes");
|
||||
|
||||
b.Property<DateTime>("UpdatedAt")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnName("updated-at");
|
||||
|
||||
b.HasKey("Id")
|
||||
.HasName("pk-managed-library-root");
|
||||
|
||||
b.HasIndex("Path")
|
||||
.IsUnique()
|
||||
.HasDatabaseName("idx-managed-library-root-path");
|
||||
|
||||
b.ToTable("managed-library-root", t =>
|
||||
{
|
||||
t.HasComment("文件库根目录");
|
||||
});
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Avalonia_EFCore.Models.UserEntity", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
@@ -170,6 +327,22 @@ namespace Avalonia_EFCore.Migrations.SQLite
|
||||
t.HasComment("天气预报数据实体");
|
||||
});
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Avalonia_EFCore.Models.ManagedFileRecord", b =>
|
||||
{
|
||||
b.HasOne("Avalonia_EFCore.Models.ManagedLibraryRoot", "LibraryRoot")
|
||||
.WithMany("Files")
|
||||
.HasForeignKey("LibraryRootId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("LibraryRoot");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Avalonia_EFCore.Models.ManagedLibraryRoot", b =>
|
||||
{
|
||||
b.Navigation("Files");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace Avalonia_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 Avalonia_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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user