using Microsoft.EntityFrameworkCore; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; namespace FileShare_EFCore.Models { /// /// 扫描入库的可在线查看文件。 /// [Comment("文件库文件记录")] [Table("managed-file-record")] public class ManagedFileRecord { /// 主键 ID。 [Key] [Column("id")] [DatabaseGenerated(DatabaseGeneratedOption.Identity)] public int Id { get; set; } /// 所属根目录 ID。 [Column("library-root-id")] public int LibraryRootId { get; set; } /// 文件名。 [Column("file-name")] [MaxLength(260)] public string FileName { get; set; } = string.Empty; /// 相对根目录路径。 [Column("relative-path")] [MaxLength(1024)] public string RelativePath { get; set; } = string.Empty; /// 服务器本机绝对路径。 [Column("absolute-path")] [MaxLength(2048)] public string AbsolutePath { get; set; } = string.Empty; /// 扩展名,小写并包含点。 [Column("extension")] [MaxLength(32)] public string Extension { get; set; } = string.Empty; /// 文件大小,字节。 [Column("size-bytes")] public long SizeBytes { get; set; } /// 文件最后修改时间 UTC。 [Column("last-write-time-utc")] public DateTime LastWriteTimeUtc { get; set; } /// 媒体类型:text、video、audio。 [Column("media-type")] [MaxLength(20)] public string MediaType { get; set; } = string.Empty; /// MIME 类型。 [Column("content-type")] [MaxLength(100)] public string ContentType { get; set; } = "application/octet-stream"; /// 文件是否仍存在。 [Column("exists")] public bool Exists { get; set; } = true; /// 最近扫描时间。 [Column("last-seen-at")] public DateTime LastSeenAt { get; set; } = DateTime.UtcNow; /// 视频缩略图路径(相对于 wwwroot)。 [Column("thumbnail-id")] public int? ThumbnailId { get; set; } /// 视频时长(秒)。 [Column("video-duration")] public double? VideoDuration { get; set; } /// 最近一次播放时间 UTC。 [Column("last-played-at")] public DateTime? LastPlayedAt { get; set; } /// 创建时间。 [Column("created-at")] public DateTime CreatedAt { get; set; } = DateTime.UtcNow; /// 更新时间。 [Column("updated-at")] public DateTime UpdatedAt { get; set; } = DateTime.UtcNow; /// 所属根目录。 public ManagedLibraryRoot? LibraryRoot { get; set; } public ManagedThumbnailMap? Thumbnail { get; set; } } }