mirror of
https://github.com/collinbarrett/FilterLists.git
synced 2026-03-11 09:04:27 +00:00
feat(dir): ✨ add IsApproved column to aggregate roots
This commit is contained in:
parent
72ef264486
commit
73b37dec2c
8 changed files with 48 additions and 21 deletions
|
|
@ -0,0 +1,20 @@
|
|||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
|
||||
namespace FilterLists.Directory.Infrastructure.Persistence.Queries.Entities;
|
||||
|
||||
public abstract record AggregateRoot
|
||||
{
|
||||
public bool? IsApproved { get; private init; }
|
||||
}
|
||||
|
||||
internal abstract class AggregateRootTypeConfiguration<TAggregateRoot> : IEntityTypeConfiguration<TAggregateRoot>
|
||||
where TAggregateRoot : AggregateRoot
|
||||
{
|
||||
public virtual void Configure(EntityTypeBuilder<TAggregateRoot> builder)
|
||||
{
|
||||
builder.Property(e => e.IsApproved)
|
||||
.IsRequired()
|
||||
.HasDefaultValue(true); // legacy json data approved via GitHub PR
|
||||
}
|
||||
}
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
namespace FilterLists.Directory.Infrastructure.Persistence.Queries.Entities;
|
||||
|
||||
public record FilterList
|
||||
public record FilterList : AggregateRoot
|
||||
{
|
||||
public int Id { get; init; }
|
||||
public string Name { get; init; } = null!;
|
||||
|
|
@ -32,9 +32,9 @@ public record FilterList
|
|||
public IReadOnlyCollection<Dependent> DependentFilterLists { get; } = new HashSet<Dependent>();
|
||||
}
|
||||
|
||||
internal class FilterListTypeConfiguration : IEntityTypeConfiguration<FilterList>
|
||||
internal class FilterListTypeConfiguration : AggregateRootTypeConfiguration<FilterList>
|
||||
{
|
||||
public virtual void Configure(EntityTypeBuilder<FilterList> builder)
|
||||
public override void Configure(EntityTypeBuilder<FilterList> builder)
|
||||
{
|
||||
builder.HasIndex(f => f.Name)
|
||||
.IsUnique();
|
||||
|
|
@ -44,5 +44,6 @@ public virtual void Configure(EntityTypeBuilder<FilterList> builder)
|
|||
.WithMany(l => l.FilterLists)
|
||||
.OnDelete(DeleteBehavior.Restrict);
|
||||
builder.HasDataJsonFile<FilterList>();
|
||||
base.Configure(builder);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,16 +3,16 @@
|
|||
|
||||
namespace FilterLists.Directory.Infrastructure.Persistence.Queries.Entities;
|
||||
|
||||
public record Language
|
||||
public record Language : AggregateRoot
|
||||
{
|
||||
public string Iso6391 { get; init; } = null!;
|
||||
public string Name { get; init; } = null!;
|
||||
public IReadOnlyCollection<FilterListLanguage> FilterListLanguages { get; } = new HashSet<FilterListLanguage>();
|
||||
}
|
||||
|
||||
internal class LanguageTypeConfiguration : IEntityTypeConfiguration<Language>
|
||||
internal class LanguageTypeConfiguration : AggregateRootTypeConfiguration<Language>
|
||||
{
|
||||
public virtual void Configure(EntityTypeBuilder<Language> builder)
|
||||
public override void Configure(EntityTypeBuilder<Language> builder)
|
||||
{
|
||||
builder.HasKey(l => l.Iso6391);
|
||||
builder.Property(l => l.Iso6391)
|
||||
|
|
@ -21,5 +21,6 @@ public virtual void Configure(EntityTypeBuilder<Language> builder)
|
|||
builder.HasIndex(l => l.Name)
|
||||
.IsUnique();
|
||||
builder.HasDataJsonFile<Language>();
|
||||
base.Configure(builder);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
namespace FilterLists.Directory.Infrastructure.Persistence.Queries.Entities;
|
||||
|
||||
public record License
|
||||
public record License : AggregateRoot
|
||||
{
|
||||
public int Id { get; init; }
|
||||
public string Name { get; init; } = null!;
|
||||
|
|
@ -14,9 +14,9 @@ public record License
|
|||
public IReadOnlyCollection<FilterList> FilterLists { get; } = new HashSet<FilterList>();
|
||||
}
|
||||
|
||||
internal class LicenseTypeConfiguration : IEntityTypeConfiguration<License>
|
||||
internal class LicenseTypeConfiguration : AggregateRootTypeConfiguration<License>
|
||||
{
|
||||
public virtual void Configure(EntityTypeBuilder<License> builder)
|
||||
public override void Configure(EntityTypeBuilder<License> builder)
|
||||
{
|
||||
builder.HasIndex(l => l.Name)
|
||||
.IsUnique();
|
||||
|
|
@ -27,5 +27,6 @@ public virtual void Configure(EntityTypeBuilder<License> builder)
|
|||
builder.Property(l => l.PermitsCommercialUse)
|
||||
.HasDefaultValue(false);
|
||||
builder.HasDataJsonFile<License>();
|
||||
base.Configure(builder);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
namespace FilterLists.Directory.Infrastructure.Persistence.Queries.Entities;
|
||||
|
||||
public record Maintainer
|
||||
public record Maintainer : AggregateRoot
|
||||
{
|
||||
public int Id { get; init; }
|
||||
public string Name { get; init; } = null!;
|
||||
|
|
@ -13,12 +13,13 @@ public record Maintainer
|
|||
public IReadOnlyCollection<FilterListMaintainer> FilterListMaintainers { get; } = new HashSet<FilterListMaintainer>();
|
||||
}
|
||||
|
||||
internal class MaintainerTypeConfiguration : IEntityTypeConfiguration<Maintainer>
|
||||
internal class MaintainerTypeConfiguration : AggregateRootTypeConfiguration<Maintainer>
|
||||
{
|
||||
public virtual void Configure(EntityTypeBuilder<Maintainer> builder)
|
||||
public override void Configure(EntityTypeBuilder<Maintainer> builder)
|
||||
{
|
||||
builder.HasIndex(m => m.Name)
|
||||
.IsUnique();
|
||||
builder.HasDataJsonFile<Maintainer>();
|
||||
base.Configure(builder);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
namespace FilterLists.Directory.Infrastructure.Persistence.Queries.Entities;
|
||||
|
||||
public record Software
|
||||
public record Software : AggregateRoot
|
||||
{
|
||||
public int Id { get; init; }
|
||||
public string Name { get; init; } = null!;
|
||||
|
|
@ -14,14 +14,15 @@ public record Software
|
|||
public IReadOnlyCollection<SoftwareSyntax> SoftwareSyntaxes { get; } = new HashSet<SoftwareSyntax>();
|
||||
}
|
||||
|
||||
internal class SoftwareTypeConfiguration : IEntityTypeConfiguration<Software>
|
||||
internal class SoftwareTypeConfiguration : AggregateRootTypeConfiguration<Software>
|
||||
{
|
||||
public virtual void Configure(EntityTypeBuilder<Software> builder)
|
||||
public override void Configure(EntityTypeBuilder<Software> builder)
|
||||
{
|
||||
builder.HasIndex(s => s.Name)
|
||||
.IsUnique();
|
||||
builder.Property(s => s.SupportsAbpUrlScheme)
|
||||
.HasDefaultValue(false);
|
||||
builder.HasDataJsonFile<Software>();
|
||||
base.Configure(builder);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
namespace FilterLists.Directory.Infrastructure.Persistence.Queries.Entities;
|
||||
|
||||
public record Syntax
|
||||
public record Syntax : AggregateRoot
|
||||
{
|
||||
public int Id { get; init; }
|
||||
public string Name { get; init; } = null!;
|
||||
|
|
@ -13,12 +13,13 @@ public record Syntax
|
|||
public IReadOnlyCollection<SoftwareSyntax> SoftwareSyntaxes { get; } = new HashSet<SoftwareSyntax>();
|
||||
}
|
||||
|
||||
internal class SyntaxTypeConfiguration : IEntityTypeConfiguration<Syntax>
|
||||
internal class SyntaxTypeConfiguration : AggregateRootTypeConfiguration<Syntax>
|
||||
{
|
||||
public virtual void Configure(EntityTypeBuilder<Syntax> builder)
|
||||
public override void Configure(EntityTypeBuilder<Syntax> builder)
|
||||
{
|
||||
builder.HasIndex(s => s.Name)
|
||||
.IsUnique();
|
||||
builder.HasDataJsonFile<Syntax>();
|
||||
base.Configure(builder);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
namespace FilterLists.Directory.Infrastructure.Persistence.Queries.Entities;
|
||||
|
||||
public record Tag
|
||||
public record Tag : AggregateRoot
|
||||
{
|
||||
public int Id { get; init; }
|
||||
public string Name { get; init; } = null!;
|
||||
|
|
@ -11,12 +11,13 @@ public record Tag
|
|||
public IReadOnlyCollection<FilterListTag> FilterListTags { get; } = new HashSet<FilterListTag>();
|
||||
}
|
||||
|
||||
internal class TagTypeConfiguration : IEntityTypeConfiguration<Tag>
|
||||
internal class TagTypeConfiguration : AggregateRootTypeConfiguration<Tag>
|
||||
{
|
||||
public virtual void Configure(EntityTypeBuilder<Tag> builder)
|
||||
public override void Configure(EntityTypeBuilder<Tag> builder)
|
||||
{
|
||||
builder.HasIndex(t => t.Name)
|
||||
.IsUnique();
|
||||
builder.HasDataJsonFile<Tag>();
|
||||
base.Configure(builder);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue