- PersonRepository, AlbumRepository, AssetRepository, MediaRepository, StatsRepository: visibility-based filtering - IAlbumRepository, IAssetRepository, IMediaRepository: updated signatures (FindByUploader, uploadedBy param, accessLevel) - AlbumController, AssetController, PersonController, MediaController: replace IsPubliclyShared/SharedWith/UserOwnerId/Owner with Visibility/UploadedBy/Uploader - FileSystemCrawlJob: IsPubliclyShared=false → Visibility=EVisibility.Private - Asset model: nav property UploadedBy→Uploader to avoid FK/nav name collision
176 lines
5.2 KiB
C#
176 lines
5.2 KiB
C#
using Butter.Types;
|
|
using System.Collections;
|
|
using System.ComponentModel.DataAnnotations;
|
|
using System.ComponentModel.DataAnnotations.Schema;
|
|
|
|
namespace Lactose.Models;
|
|
|
|
/// <summary>
|
|
/// Represents an asset in the system.
|
|
/// </summary>
|
|
[Index(nameof(OriginalPath), IsUnique = true)]
|
|
public class Asset {
|
|
/// <summary>
|
|
/// Gets or sets the unique identifier for the asset.
|
|
/// </summary>
|
|
[Key]
|
|
public Guid Id { get; set; }
|
|
|
|
/// <summary>
|
|
/// Gets or sets the original path of the asset.
|
|
/// </summary>
|
|
[Column(TypeName = "VARCHAR(2048)")]
|
|
public required string OriginalPath { get; set; } = string.Empty;
|
|
|
|
/// <summary>
|
|
/// Gets or sets the original filename of the asset.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// This is needed to preserve the original filename when the asset is uploaded from the web as it would be renamed to avoid filename collisions.
|
|
/// </remarks>
|
|
[Column(TypeName = "VARCHAR(255)")]
|
|
public required string OriginalFilename { get; set; } = string.Empty;
|
|
|
|
/// <summary>
|
|
/// Gets or sets the thumbnail path of the asset.
|
|
/// </summary>
|
|
[Column(TypeName = "VARCHAR(2048)")]
|
|
public string ThumbnailPath { get; set; } = string.Empty;
|
|
|
|
/// <summary>
|
|
/// Gets or sets the longest-side size in pixels of the generated thumbnail.
|
|
/// Zero means no thumbnail has been generated.
|
|
/// </summary>
|
|
public int ThumbnailSize { get; set; }
|
|
|
|
/// <summary>
|
|
/// Gets or sets the format of the generated thumbnail (e.g. "webp").
|
|
/// Used to detect when thumbnails need regeneration due to format changes.
|
|
/// </summary>
|
|
[Column(TypeName = "VARCHAR(16)")]
|
|
public string ThumbnailFormat { get; set; } = string.Empty;
|
|
|
|
/// <summary>
|
|
/// Gets or sets the preview path of the asset.
|
|
/// </summary>
|
|
[Column(TypeName = "VARCHAR(2048)")]
|
|
public string PreviewPath { get; set; } = string.Empty;
|
|
|
|
/// <summary>
|
|
/// Gets or sets the longest-side size in pixels of the generated preview.
|
|
/// Zero means no preview has been generated.
|
|
/// </summary>
|
|
public int PreviewSize { get; set; }
|
|
|
|
/// <summary>
|
|
/// Gets or sets the format of the generated preview (e.g. "webp").
|
|
/// Used to detect when previews need regeneration due to format changes.
|
|
/// </summary>
|
|
[Column(TypeName = "VARCHAR(16)")]
|
|
public string PreviewFormat { get; set; } = string.Empty;
|
|
|
|
/// <summary>
|
|
/// Gets or sets the type of the asset.
|
|
/// </summary>
|
|
public required EAssetType Type { get; set; }
|
|
|
|
/// <summary>
|
|
/// Gets or sets the ID of the user who uploaded the asset.
|
|
/// </summary>
|
|
[ForeignKey(nameof(UploadedBy))]
|
|
public Guid? UploadedBy { get; set; }
|
|
|
|
/// <summary>
|
|
/// Gets or sets the visibility level of the asset.
|
|
/// </summary>
|
|
public EVisibility Visibility { get; set; }
|
|
|
|
/// <summary>
|
|
/// Gets or sets the creation date of the asset.
|
|
/// </summary>
|
|
[Required]
|
|
public required DateTime CreatedAt { get; set; } = DateTime.UtcNow;
|
|
|
|
/// <summary>
|
|
/// Gets or sets the last updated date of the asset.
|
|
/// </summary>
|
|
public DateTime? UpdatedAt { get; set; }
|
|
|
|
/// <summary>
|
|
/// Gets or sets the deletion date of the asset.
|
|
/// </summary>
|
|
public DateTime? DeletedAt { get; set; }
|
|
|
|
/// <summary>
|
|
/// Gets or sets the MIME type of the asset.
|
|
/// </summary>
|
|
[Required][Column(TypeName = "VARCHAR(255)")]
|
|
public string MimeType { get; set; } = string.Empty;
|
|
|
|
/// <summary>
|
|
/// Gets or sets the resolution width of the asset.
|
|
/// </summary>
|
|
public int ResolutionWidth { get; set; }
|
|
|
|
/// <summary>
|
|
/// Gets or sets the resolution height of the asset.
|
|
/// </summary>
|
|
public int ResolutionHeight { get; set; }
|
|
|
|
/// <summary>
|
|
/// Gets or sets the file size of the asset.
|
|
/// </summary>
|
|
public long FileSize { get; set; }
|
|
|
|
/// <summary>
|
|
/// Gets or sets the duration of the asset.
|
|
/// </summary>
|
|
public float? Duration { get; set; }
|
|
|
|
/// <summary>
|
|
/// Gets or sets the frame rate of the asset.
|
|
/// </summary>
|
|
public float? FrameRate { get; set; }
|
|
|
|
/// <summary>
|
|
/// Computed hash of the asset.
|
|
/// </summary>
|
|
[Required][Column(TypeName = "bit(64)")]
|
|
public BitArray Hash { get; set; } = new BitArray(64);
|
|
|
|
/// <summary>
|
|
/// Gets or Sets which folder the asset is in.
|
|
/// </summary>
|
|
[ForeignKey(nameof(Folder))]
|
|
public Guid? FolderId { get; set; }
|
|
|
|
#region Navigation Properties
|
|
|
|
/// <summary>
|
|
/// Gets or sets the user who uploaded the asset.
|
|
/// </summary>
|
|
public User? Uploader { get; set; }
|
|
|
|
/// <summary>
|
|
/// Gets or sets the list of albums associated with the asset.
|
|
/// </summary>
|
|
public List<Album>? Albums { get; set; }
|
|
|
|
/// <summary>
|
|
/// Gets or sets the list of tags associated with the asset.
|
|
/// </summary>
|
|
public List<Tag>? Tags { get; set; }
|
|
|
|
/// <summary>
|
|
/// Gets or sets the list of faces detected in the asset.
|
|
/// </summary>
|
|
public List<Face>? Faces { get; set; }
|
|
|
|
/// <summary>
|
|
/// Gets or sets the folder containing the asset.
|
|
/// </summary>
|
|
public Folder? Folder { get; set; }
|
|
|
|
#endregion
|
|
}
|