mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 10:11:10 +00:00
Moves media library scanning to domain layer
This commit is contained in:
1 parent
8b51abe0b2
commit
c4246d2e69
209 files changed
+3793
-641
No files matched your search
@@ -202,6 +202,23 @@ public class BookConfiguration : IEntityTypeConfiguration<BookEntity>
|
||||
.HasMaxLength(6)
|
||||
.IsRequired();
|
||||
});
|
||||
|
||||
// audit
|
||||
builder.Property(permission => permission.CreatedOnUtc)
|
||||
.IsRequired()
|
||||
.HasColumnOrder(32);
|
||||
|
||||
builder.Property(permission => permission.CreatedBy)
|
||||
.IsRequired()
|
||||
.HasColumnOrder(33);
|
||||
|
||||
builder.Property(permission => permission.UpdatedOnUtc)
|
||||
.HasDefaultValue(null)
|
||||
.HasColumnOrder(34);
|
||||
|
||||
builder.Property(permission => permission.UpdatedBy)
|
||||
.HasDefaultValue(null)
|
||||
.HasColumnOrder(35);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -59,6 +59,12 @@ public class LibraryConfiguration : IEntityTypeConfiguration<LibraryEntity>
|
||||
.HasForeignKey(library => library.UserId)
|
||||
.IsRequired();
|
||||
|
||||
// one library with many scans
|
||||
builder.HasMany(library => library.LibraryScans)
|
||||
.WithOne(libraryScan => libraryScan.Library)
|
||||
.HasForeignKey(libraryScan => libraryScan.LibraryId)
|
||||
.OnDelete(DeleteBehavior.Cascade); // deleting a library deletes library scans
|
||||
|
||||
// using OwnsMany because paths are domain Value Objects, thus they have no independent identity, and their lifecycle is bound to the Library
|
||||
builder.OwnsMany(library => library.ContentLocations, contentLocationBuilder =>
|
||||
{
|
||||
@@ -75,5 +81,22 @@ public class LibraryConfiguration : IEntityTypeConfiguration<LibraryEntity>
|
||||
.HasMaxLength(260)
|
||||
.IsRequired();
|
||||
});
|
||||
|
||||
// audit
|
||||
builder.Property(permission => permission.CreatedOnUtc)
|
||||
.IsRequired()
|
||||
.HasColumnOrder(8);
|
||||
|
||||
builder.Property(permission => permission.CreatedBy)
|
||||
.IsRequired()
|
||||
.HasColumnOrder(9);
|
||||
|
||||
builder.Property(permission => permission.UpdatedOnUtc)
|
||||
.HasDefaultValue(null)
|
||||
.HasColumnOrder(10);
|
||||
|
||||
builder.Property(permission => permission.UpdatedBy)
|
||||
.HasDefaultValue(null)
|
||||
.HasColumnOrder(11);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using System;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.DataAccess.Common.Configuration;
|
||||
|
||||
/// <summary>
|
||||
/// Configures the entity mapping for the <see cref="LibraryScanEntity"/> entity.
|
||||
/// </summary>
|
||||
public class LibraryScanConfiguration : IEntityTypeConfiguration<LibraryScanEntity>
|
||||
{
|
||||
/// <summary>
|
||||
/// Configures the <see cref="LibraryScanEntity"/> entity.
|
||||
/// </summary>
|
||||
/// <param name="builder">The builder to be used to configure the entity.</param>
|
||||
public void Configure(EntityTypeBuilder<LibraryScanEntity> builder)
|
||||
{
|
||||
builder.ToTable("LibraryScans");
|
||||
builder.HasKey(library => library.Id);
|
||||
builder.Property(library => library.Id)
|
||||
.ValueGeneratedNever() // because EF always tries to generate the value for the Id, and because we generate it as part of the aggregate root, we need to tell EF not to generate it
|
||||
.HasColumnOrder(0);
|
||||
|
||||
// one user with many library scans
|
||||
builder.HasOne(libraryScan => libraryScan.User)
|
||||
.WithMany(user => user.LibraryScans)
|
||||
.HasForeignKey(libraryScan => libraryScan.UserId)
|
||||
.IsRequired();
|
||||
|
||||
// one library with many library scans
|
||||
builder.HasOne(libraryScan => libraryScan.Library)
|
||||
.WithMany(library => library.LibraryScans)
|
||||
.HasForeignKey(libraryScan => libraryScan.LibraryId)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(libraryScan => libraryScan.Status)
|
||||
.IsRequired()
|
||||
.HasConversion<string>()
|
||||
.HasColumnOrder(1);
|
||||
|
||||
// audit
|
||||
builder.Property(permission => permission.CreatedOnUtc)
|
||||
.IsRequired()
|
||||
.HasColumnOrder(2);
|
||||
|
||||
builder.Property(permission => permission.CreatedBy)
|
||||
.IsRequired()
|
||||
.HasColumnOrder(3);
|
||||
|
||||
builder.Property(permission => permission.UpdatedOnUtc)
|
||||
.HasDefaultValue(null)
|
||||
.HasColumnOrder(4);
|
||||
|
||||
builder.Property(permission => permission.UpdatedBy)
|
||||
.HasDefaultValue(null)
|
||||
.HasColumnOrder(5);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user