mirror of
https://github.com/collinbarrett/FilterLists.git
synced 2026-03-11 09:04:27 +00:00
feat(dir): ✨ scaffold rest of aggregates
This commit is contained in:
parent
da1e4bfa88
commit
700f5001ec
18 changed files with 134 additions and 44 deletions
|
|
@ -1,5 +1,9 @@
|
|||
using FilterLists.Directory.Domain.Aggregates.Changes;
|
||||
using FilterLists.Directory.Domain.Aggregates.Languages;
|
||||
using FilterLists.Directory.Domain.Aggregates.Licenses;
|
||||
using FilterLists.Directory.Domain.Aggregates.Maintainers;
|
||||
using FilterLists.Directory.Domain.Aggregates.Syntaxes;
|
||||
using FilterLists.Directory.Domain.Aggregates.Tags;
|
||||
using FilterLists.Directory.Domain.Changes;
|
||||
using FilterLists.SharedKernel.Domain.SeedWork;
|
||||
|
||||
namespace FilterLists.Directory.Domain.Aggregates.FilterLists;
|
||||
|
|
@ -11,6 +15,9 @@ protected FilterList() { }
|
|||
public string Name { get; private init; } = default!;
|
||||
public string? Description { get; private init; }
|
||||
public virtual License License { get; private init; } = default!;
|
||||
public virtual IEnumerable<Syntax> Syntaxes { get; private init; } = new HashSet<Syntax>();
|
||||
public virtual IEnumerable<Language> Languages { get; private init; } = new HashSet<Language>();
|
||||
public virtual IEnumerable<Tag> Tags { get; private init; } = new HashSet<Tag>();
|
||||
public virtual IEnumerable<FilterListViewUrl> ViewUrls { get; private init; } = new HashSet<FilterListViewUrl>();
|
||||
public Uri? HomeUrl { get; private init; }
|
||||
public Uri? OnionUrl { get; private init; }
|
||||
|
|
@ -21,6 +28,13 @@ protected FilterList() { }
|
|||
public Uri? ChatUrl { get; private init; }
|
||||
public string? EmailAddress { get; private init; }
|
||||
public Uri? DonateUrl { get; private init; }
|
||||
public virtual IEnumerable<Maintainer> Maintainers { get; private init; } = new HashSet<Maintainer>();
|
||||
public virtual IEnumerable<FilterList> UpstreamFilterLists { get; private init; } = new HashSet<FilterList>();
|
||||
public virtual IEnumerable<FilterList> ForkFilterLists { get; private init; } = new HashSet<FilterList>();
|
||||
public virtual IEnumerable<FilterList> IncludedInFilterLists { get; private init; } = new HashSet<FilterList>();
|
||||
public virtual IEnumerable<FilterList> IncludesFilterLists { get; private init; } = new HashSet<FilterList>();
|
||||
public virtual IEnumerable<FilterList> DependencyFilterLists { get; private init; } = new HashSet<FilterList>();
|
||||
public virtual IEnumerable<FilterList> DependentFilterLists { get; private init; } = new HashSet<FilterList>();
|
||||
public virtual IEnumerable<FilterListChange> Changes { get; private set; } = new HashSet<FilterListChange>();
|
||||
public bool IsApproved { get; private init; }
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
using FilterLists.Directory.Domain.Aggregates.FilterLists;
|
||||
using FilterLists.Directory.Domain.Changes;
|
||||
|
||||
namespace FilterLists.Directory.Domain.Aggregates.Changes;
|
||||
namespace FilterLists.Directory.Domain.Aggregates.FilterLists;
|
||||
|
||||
public class FilterListChange : Change, IChangeAggregate<FilterListValueObject>
|
||||
{
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
using FilterLists.Directory.Domain.Aggregates.FilterLists;
|
||||
using FilterLists.SharedKernel.Domain.SeedWork;
|
||||
|
||||
namespace FilterLists.Directory.Domain.Aggregates.Languages;
|
||||
|
||||
public class Language : Entity
|
||||
{
|
||||
protected Language() { }
|
||||
|
||||
public string Iso6391 { get; private init; } = default!;
|
||||
public string Name { get; private init; } = default!;
|
||||
public virtual IEnumerable<FilterList> FilterLists { get; private init; } = new HashSet<FilterList>();
|
||||
}
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
using FilterLists.SharedKernel.Domain.SeedWork;
|
||||
using FilterLists.Directory.Domain.Aggregates.FilterLists;
|
||||
using FilterLists.SharedKernel.Domain.SeedWork;
|
||||
|
||||
namespace FilterLists.Directory.Domain.Aggregates.Licenses;
|
||||
|
||||
|
|
@ -11,21 +12,5 @@ protected License() { }
|
|||
public bool PermitsModification { get; private init; }
|
||||
public bool PermitsDistribution { get; private init; }
|
||||
public bool PermitsCommercialUse { get; private init; }
|
||||
|
||||
public static License Create(
|
||||
string name,
|
||||
Uri? url,
|
||||
bool permitsModification,
|
||||
bool permitsDistribution,
|
||||
bool permitsCommercialUse)
|
||||
{
|
||||
return new License
|
||||
{
|
||||
Name = name,
|
||||
Url = url,
|
||||
PermitsModification = permitsModification,
|
||||
PermitsDistribution = permitsDistribution,
|
||||
PermitsCommercialUse = permitsCommercialUse
|
||||
};
|
||||
}
|
||||
public virtual IEnumerable<FilterList> FilterLists { get; private init; } = new HashSet<FilterList>();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,15 @@
|
|||
using FilterLists.Directory.Domain.Aggregates.FilterLists;
|
||||
using FilterLists.SharedKernel.Domain.SeedWork;
|
||||
|
||||
namespace FilterLists.Directory.Domain.Aggregates.Maintainers;
|
||||
|
||||
public class Maintainer : Entity
|
||||
{
|
||||
protected Maintainer() { }
|
||||
|
||||
public string Name { get; private init; } = default!;
|
||||
public Uri? Url { get; private init; }
|
||||
public string? EmailAddress { get; private init; }
|
||||
public string? TwitterHandle { get; private init; }
|
||||
public virtual IEnumerable<FilterList> FilterLists { get; private init; } = new HashSet<FilterList>();
|
||||
}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
using FilterLists.Directory.Domain.Aggregates.Syntaxes;
|
||||
using FilterLists.SharedKernel.Domain.SeedWork;
|
||||
|
||||
namespace FilterLists.Directory.Domain.Aggregates.Software;
|
||||
|
||||
public class Software : Entity
|
||||
{
|
||||
protected Software() { }
|
||||
|
||||
public string Name { get; private init; } = default!;
|
||||
public string? Description { get; private init; }
|
||||
public Uri? HomeUrl { get; private init; }
|
||||
public Uri? DownloadUrl { get; private init; }
|
||||
public bool SupportsAbpUrlScheme { get; private init; }
|
||||
public virtual IEnumerable<Syntax> Syntaxes { get; private init; } = new HashSet<Syntax>();
|
||||
}
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
using FilterLists.Directory.Domain.Aggregates.FilterLists;
|
||||
using FilterLists.SharedKernel.Domain.SeedWork;
|
||||
|
||||
namespace FilterLists.Directory.Domain.Aggregates.Syntaxes;
|
||||
|
||||
public class Syntax : Entity
|
||||
{
|
||||
protected Syntax() { }
|
||||
|
||||
public string Name { get; private init; } = default!;
|
||||
public string? Description { get; private init; }
|
||||
public Uri? Url { get; private init; }
|
||||
public virtual IEnumerable<FilterList> FilterLists { get; private init; } = new HashSet<FilterList>();
|
||||
public virtual IEnumerable<Software.Software> Software { get; private init; } = new HashSet<Software.Software>();
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
using FilterLists.Directory.Domain.Aggregates.FilterLists;
|
||||
using FilterLists.SharedKernel.Domain.SeedWork;
|
||||
|
||||
namespace FilterLists.Directory.Domain.Aggregates.Tags;
|
||||
|
||||
public class Tag : Entity
|
||||
{
|
||||
protected Tag() { }
|
||||
|
||||
public string Name { get; private init; } = default!;
|
||||
public string? Description { get; private init; }
|
||||
public virtual IEnumerable<FilterList> FilterLists { get; private init; } = new HashSet<FilterList>();
|
||||
}
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
using FilterLists.SharedKernel.Domain.SeedWork;
|
||||
|
||||
namespace FilterLists.Directory.Domain.Aggregates.Changes;
|
||||
namespace FilterLists.Directory.Domain.Changes;
|
||||
|
||||
public abstract class Change : Entity
|
||||
{
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
using FilterLists.SharedKernel.Domain.SeedWork;
|
||||
|
||||
namespace FilterLists.Directory.Domain.Aggregates.Changes;
|
||||
namespace FilterLists.Directory.Domain.Changes;
|
||||
|
||||
public interface IChangeAggregate<out TAggregateValueObject> where TAggregateValueObject : ValueObject
|
||||
{
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
namespace FilterLists.Directory.Domain.Aggregates.Changes;
|
||||
namespace FilterLists.Directory.Domain.Changes;
|
||||
|
||||
public interface IRequireChangeApproval<out TChange> where TChange : Change
|
||||
{
|
||||
|
|
@ -1,6 +1,11 @@
|
|||
using FilterLists.Directory.Domain.Aggregates;
|
||||
using FilterLists.Directory.Domain.Aggregates.FilterLists;
|
||||
using FilterLists.Directory.Domain.Aggregates.Languages;
|
||||
using FilterLists.Directory.Domain.Aggregates.Licenses;
|
||||
using FilterLists.Directory.Domain.Aggregates.Maintainers;
|
||||
using FilterLists.Directory.Domain.Aggregates.Software;
|
||||
using FilterLists.Directory.Domain.Aggregates.Syntaxes;
|
||||
using FilterLists.Directory.Domain.Aggregates.Tags;
|
||||
using FilterLists.Directory.Infrastructure.Persistence.Commands.EntityTypeConfigurations;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Npgsql;
|
||||
|
|
@ -17,7 +22,12 @@ static CommandDbContext()
|
|||
public CommandDbContext(DbContextOptions<CommandDbContext> options) : base(options) { }
|
||||
|
||||
public DbSet<FilterList> FilterLists => Set<FilterList>();
|
||||
public DbSet<Language> Languages => Set<Language>();
|
||||
public DbSet<License> Licenses => Set<License>();
|
||||
public DbSet<Maintainer> Maintainers => Set<Maintainer>();
|
||||
public DbSet<Software> Software => Set<Software>();
|
||||
public DbSet<Syntax> Syntaxes => Set<Syntax>();
|
||||
public DbSet<Tag> Tags => Set<Tag>();
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,5 +1,10 @@
|
|||
using FilterLists.Directory.Domain.Aggregates.FilterLists;
|
||||
using FilterLists.Directory.Domain.Aggregates.Languages;
|
||||
using FilterLists.Directory.Domain.Aggregates.Licenses;
|
||||
using FilterLists.Directory.Domain.Aggregates.Maintainers;
|
||||
using FilterLists.Directory.Domain.Aggregates.Software;
|
||||
using FilterLists.Directory.Domain.Aggregates.Syntaxes;
|
||||
using FilterLists.Directory.Domain.Aggregates.Tags;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace FilterLists.Directory.Infrastructure.Persistence.Commands.Context;
|
||||
|
|
@ -7,6 +12,11 @@ namespace FilterLists.Directory.Infrastructure.Persistence.Commands.Context;
|
|||
public interface ICommandContext
|
||||
{
|
||||
DbSet<FilterList> FilterLists { get; }
|
||||
DbSet<Language> Languages { get; }
|
||||
DbSet<License> Licenses { get; }
|
||||
DbSet<Maintainer> Maintainers { get; }
|
||||
DbSet<Software> Software { get; }
|
||||
DbSet<Syntax> Syntaxes { get; }
|
||||
DbSet<Tag> Tags { get; }
|
||||
Task<int> SaveChangesAsync(CancellationToken cancellationToken);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
using System.Globalization;
|
||||
using EFCore.NamingConventions.Internal;
|
||||
using FilterLists.Directory.Domain.Aggregates;
|
||||
using FilterLists.Directory.Domain.Aggregates.Changes;
|
||||
using FilterLists.Directory.Domain.Aggregates.FilterLists;
|
||||
using FilterLists.Directory.Domain.Changes;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
|
||||
|
|
@ -17,6 +18,5 @@ public virtual void Configure(EntityTypeBuilder<Change> builder)
|
|||
builder.ToTable($"{nr.RewriteName(nameof(Change))}s");
|
||||
builder.HasDiscriminator<AggregateType>(nr.RewriteName(nameof(Queries.Entities.Change.AggregateType)))
|
||||
.HasValue<FilterListChange>(AggregateType.FilterList);
|
||||
builder.Property<long>(nameof(Queries.Entities.Change.Id));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using FilterLists.Directory.Domain.Aggregates.Changes;
|
||||
using FilterLists.Directory.Domain.Aggregates.FilterLists;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using Change = FilterLists.Directory.Infrastructure.Persistence.Queries.Entities.Change;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
using FilterLists.Directory.Infrastructure.Persistence.Queries.Entities;
|
||||
using System.Globalization;
|
||||
using EFCore.NamingConventions.Internal;
|
||||
using FilterLists.Directory.Infrastructure.Persistence.Queries.Entities;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using FilterList = FilterLists.Directory.Domain.Aggregates.FilterLists.FilterList;
|
||||
|
|
@ -9,8 +11,19 @@ internal class FilterListTypeConfiguration : IEntityTypeConfiguration<FilterList
|
|||
{
|
||||
public virtual void Configure(EntityTypeBuilder<FilterList> builder)
|
||||
{
|
||||
builder.Property<long>(nameof(Queries.Entities.FilterList.Id));
|
||||
builder.HasMany(c => c.Changes)
|
||||
// TODO: register and resolve INameRewriter
|
||||
var nr = new SnakeCaseNameRewriter(CultureInfo.InvariantCulture);
|
||||
|
||||
builder.HasMany(f => f.UpstreamFilterLists)
|
||||
.WithMany(f => f.ForkFilterLists)
|
||||
.UsingEntity(f => f.ToTable($"{nr.RewriteName(nameof(Fork))}s"));
|
||||
builder.HasMany(f => f.IncludedInFilterLists)
|
||||
.WithMany(f => f.IncludesFilterLists)
|
||||
.UsingEntity(f => f.ToTable($"{nr.RewriteName(nameof(Merge))}s"));
|
||||
builder.HasMany(f => f.DependencyFilterLists)
|
||||
.WithMany(f => f.DependentFilterLists)
|
||||
.UsingEntity(f => f.ToTable($"{nr.RewriteName(nameof(Dependent))}s"));
|
||||
builder.HasMany(f => f.Changes)
|
||||
.WithOne()
|
||||
.HasForeignKey(nameof(Change.FilterListId));
|
||||
builder.Navigation(f => f.Changes)
|
||||
|
|
|
|||
|
|
@ -14,6 +14,5 @@ public virtual void Configure(EntityTypeBuilder<FilterListViewUrl> builder)
|
|||
var nr = new SnakeCaseNameRewriter(CultureInfo.InvariantCulture);
|
||||
|
||||
builder.ToTable($"{nr.RewriteName(nameof(Queries.Entities.FilterListViewUrl))}s");
|
||||
builder.Property<long>(nameof(Queries.Entities.FilterListViewUrl.Id));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,13 +0,0 @@
|
|||
using FilterLists.Directory.Domain.Aggregates.Licenses;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
|
||||
namespace FilterLists.Directory.Infrastructure.Persistence.Commands.EntityTypeConfigurations;
|
||||
|
||||
internal class LicenseTypeConfiguration : IEntityTypeConfiguration<License>
|
||||
{
|
||||
public virtual void Configure(EntityTypeBuilder<License> builder)
|
||||
{
|
||||
builder.Property<long>(nameof(Queries.Entities.License.Id));
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue