-
Notifications
You must be signed in to change notification settings - Fork 0
Eternelle-180 Catalog Module #181
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 28 commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
1b819b6
feat(catalog): scaffold five-project module structure
engrkwakwak 75139b7
feat(catalog): add TemplateTier, PriceClass, SectionId enums
engrkwakwak ab649c5
feat(catalog): add strongly-typed ids for Template and children
engrkwakwak e88b1bd
feat(catalog): add value objects and errors
engrkwakwak e159b63
feat(catalog): add jsonb theme styling records
engrkwakwak 5567a65
feat(catalog): add Template child entities with variant upload limit
engrkwakwak d503809
feat(catalog): add Template domain events and manifest payload
engrkwakwak f1ca0ce
feat(catalog): add TemplateErrors
engrkwakwak 8b245d6
feat(catalog): add Template aggregate root
engrkwakwak ba49d6e
feat(catalog): add ITemplateRepository
engrkwakwak 0eb10cf
style(catalog): remove what-comment from UploadLimit property
engrkwakwak 724f3fe
Eternelle-180 Add CatalogTemplateManifestChanged integration event
engrkwakwak 29b8351
Eternelle-180 Add IUnitOfWork and manifest domain-event handler
engrkwakwak 033c22c
Eternelle-180 Add CreateTemplate command and cache keys
engrkwakwak 5027920
Eternelle-180 Add UpdateTemplate command
engrkwakwak 09703e6
Eternelle-180 Add AddTemplateTheme command
engrkwakwak 8c828d5
Eternelle-180 Add AddSupportedSection command
engrkwakwak 942a68b
Eternelle-180 Add AddSectionVariant command with upload limit
engrkwakwak febdab8
Eternelle-180 Add GetTemplates query
engrkwakwak af8134e
Eternelle-180 Add GetTemplateById query
engrkwakwak 231b6b5
Eternelle-180 Add GetSupportedSections and GetSectionVariants queries
engrkwakwak e7f88ee
Eternelle-180 Add CatalogDbContext, id converters, and entity configu…
engrkwakwak e4d23ee
Eternelle-180 Add TemplateRepository
engrkwakwak bf5d704
Eternelle-180 Add outbox plumbing and CatalogModule DI
engrkwakwak 70bf5ea
Eternelle-180 Add presentation layer endpoints (Tasks 26-27)
engrkwakwak 6be8d99
Eternelle-180 Wire Catalog module into the API host and add initial m…
engrkwakwak 23873b5
Eternelle-180 Seed catalog:manage permission for Admin role
engrkwakwak 0d94173
Eternelle-180 Apply file-scoped namespace and collection expression f…
engrkwakwak 7ec9a03
Eternelle-180 Add migration support for CatalogDbContext
engrkwakwak fef0171
Eternelle-180 Address code review findings on Template aggregate and …
engrkwakwak 8169c19
Eternelle-180 Refactor init patterns, migrations, and add comments
engrkwakwak File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| { | ||
| "Catalog": { | ||
| "Outbox": { | ||
| "IntervalInSeconds": 10, | ||
| "BatchSize": 10 | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| { | ||
| "Catalog": { | ||
| "Outbox": { | ||
| "IntervalInSeconds": 10, | ||
| "BatchSize": 10 | ||
| } | ||
| } | ||
| } |
6 changes: 6 additions & 0 deletions
6
src/Modules/Catalog/Eternelle.Modules.Catalog.Application/Abstractions/Data/IUnitOfWork.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| namespace Eternelle.Modules.Catalog.Application.Abstractions.Data; | ||
|
|
||
| public interface IUnitOfWork | ||
| { | ||
| Task<int> SaveChangesAsync(CancellationToken cancellationToken = default); | ||
| } |
8 changes: 8 additions & 0 deletions
8
src/Modules/Catalog/Eternelle.Modules.Catalog.Application/AssemblyReference.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| using System.Reflection; | ||
|
|
||
| namespace Eternelle.Modules.Catalog.Application; | ||
|
|
||
| public static class AssemblyReference | ||
| { | ||
| public static readonly Assembly Assembly = typeof(AssemblyReference).Assembly; | ||
| } |
9 changes: 9 additions & 0 deletions
9
...atalog/Eternelle.Modules.Catalog.Application/Eternelle.Modules.Catalog.Application.csproj
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
|
|
||
| <ItemGroup> | ||
| <ProjectReference Include="..\Eternelle.Modules.Catalog.Domain\Eternelle.Modules.Catalog.Domain.csproj" /> | ||
| <ProjectReference Include="..\Eternelle.Modules.Catalog.IntegrationEvents\Eternelle.Modules.Catalog.IntegrationEvents.csproj" /> | ||
| <ProjectReference Include="..\..\..\Common\Eternelle.Common.Application\Eternelle.Common.Application.csproj" /> | ||
| </ItemGroup> | ||
|
|
||
| </Project> |
12 changes: 12 additions & 0 deletions
12
...nelle.Modules.Catalog.Application/Templates/AddSectionVariant/AddSectionVariantCommand.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| using Eternelle.Common.Application.Messaging; | ||
| using Eternelle.Modules.Catalog.Domain.Templates; | ||
|
|
||
| namespace Eternelle.Modules.Catalog.Application.Templates.AddSectionVariant; | ||
|
|
||
| public sealed record AddSectionVariantCommand( | ||
| Guid TemplateId, | ||
| SectionId SectionId, | ||
| string Variant, | ||
| bool IsDefault, | ||
| PriceClass PriceClass, | ||
| int? UploadLimit) : ICommand; |
39 changes: 39 additions & 0 deletions
39
...odules.Catalog.Application/Templates/AddSectionVariant/AddSectionVariantCommandHandler.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| using Eternelle.Common.Application.Caching; | ||
| using Eternelle.Common.Application.Clock; | ||
| using Eternelle.Common.Application.Messaging; | ||
| using Eternelle.Common.Domain; | ||
| using Eternelle.Modules.Catalog.Application.Abstractions.Data; | ||
| using Eternelle.Modules.Catalog.Domain.Templates; | ||
|
|
||
| namespace Eternelle.Modules.Catalog.Application.Templates.AddSectionVariant; | ||
|
|
||
| internal sealed class AddSectionVariantCommandHandler( | ||
| ITemplateRepository templateRepository, | ||
| IUnitOfWork unitOfWork, | ||
| ICacheService cacheService, | ||
| IDateTimeProvider dateTimeProvider) : ICommandHandler<AddSectionVariantCommand> | ||
| { | ||
| public async Task<Result> Handle(AddSectionVariantCommand command, CancellationToken cancellationToken) | ||
| { | ||
| Template? template = await templateRepository.GetAsync(new TemplateId(command.TemplateId), cancellationToken); | ||
| if (template is null) | ||
| { | ||
| return Result.Failure(TemplateErrors.NotFound(new TemplateId(command.TemplateId))); | ||
| } | ||
|
|
||
| Result addResult = template.AddSectionVariant( | ||
| command.SectionId, command.Variant.Trim(), command.IsDefault, command.PriceClass, | ||
| command.UploadLimit, dateTimeProvider.UtcNow); | ||
| if (addResult.IsFailure) | ||
| { | ||
| return addResult; | ||
| } | ||
|
|
||
| templateRepository.Update(template); | ||
| await unitOfWork.SaveChangesAsync(cancellationToken); | ||
|
|
||
| await cacheService.RemoveAsync(CatalogCacheKeys.TemplateById(command.TemplateId), cancellationToken); | ||
|
|
||
| return Result.Success(); | ||
| } | ||
| } |
15 changes: 15 additions & 0 deletions
15
...ules.Catalog.Application/Templates/AddSectionVariant/AddSectionVariantCommandValidator.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| using FluentValidation; | ||
|
|
||
| namespace Eternelle.Modules.Catalog.Application.Templates.AddSectionVariant; | ||
|
|
||
| internal sealed class AddSectionVariantCommandValidator : AbstractValidator<AddSectionVariantCommand> | ||
| { | ||
| public AddSectionVariantCommandValidator() | ||
| { | ||
| RuleFor(c => c.TemplateId).NotEmpty(); | ||
| RuleFor(c => c.SectionId).IsInEnum(); | ||
| RuleFor(c => c.Variant).NotEmpty().MaximumLength(100); | ||
| RuleFor(c => c.PriceClass).IsInEnum(); | ||
| RuleFor(c => c.UploadLimit).GreaterThan(0).When(c => c.UploadLimit is not null); | ||
| } | ||
| } | ||
9 changes: 9 additions & 0 deletions
9
...e.Modules.Catalog.Application/Templates/AddSupportedSection/AddSupportedSectionCommand.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| using Eternelle.Common.Application.Messaging; | ||
| using Eternelle.Modules.Catalog.Domain.Templates; | ||
|
|
||
| namespace Eternelle.Modules.Catalog.Application.Templates.AddSupportedSection; | ||
|
|
||
| public sealed record AddSupportedSectionCommand( | ||
| Guid TemplateId, | ||
| SectionId SectionId, | ||
| int DisplayOrder) : ICommand; |
37 changes: 37 additions & 0 deletions
37
...es.Catalog.Application/Templates/AddSupportedSection/AddSupportedSectionCommandHandler.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| using Eternelle.Common.Application.Caching; | ||
| using Eternelle.Common.Application.Clock; | ||
| using Eternelle.Common.Application.Messaging; | ||
| using Eternelle.Common.Domain; | ||
| using Eternelle.Modules.Catalog.Application.Abstractions.Data; | ||
| using Eternelle.Modules.Catalog.Domain.Templates; | ||
|
|
||
| namespace Eternelle.Modules.Catalog.Application.Templates.AddSupportedSection; | ||
|
|
||
| internal sealed class AddSupportedSectionCommandHandler( | ||
| ITemplateRepository templateRepository, | ||
| IUnitOfWork unitOfWork, | ||
| ICacheService cacheService, | ||
| IDateTimeProvider dateTimeProvider) : ICommandHandler<AddSupportedSectionCommand> | ||
| { | ||
| public async Task<Result> Handle(AddSupportedSectionCommand command, CancellationToken cancellationToken) | ||
| { | ||
| Template? template = await templateRepository.GetAsync(new TemplateId(command.TemplateId), cancellationToken); | ||
| if (template is null) | ||
| { | ||
| return Result.Failure(TemplateErrors.NotFound(new TemplateId(command.TemplateId))); | ||
| } | ||
|
|
||
| Result addResult = template.AddSupportedSection(command.SectionId, command.DisplayOrder, dateTimeProvider.UtcNow); | ||
| if (addResult.IsFailure) | ||
| { | ||
| return addResult; | ||
| } | ||
|
|
||
| templateRepository.Update(template); | ||
| await unitOfWork.SaveChangesAsync(cancellationToken); | ||
|
|
||
| await cacheService.RemoveAsync(CatalogCacheKeys.TemplateById(command.TemplateId), cancellationToken); | ||
|
|
||
| return Result.Success(); | ||
| } | ||
| } |
13 changes: 13 additions & 0 deletions
13
....Catalog.Application/Templates/AddSupportedSection/AddSupportedSectionCommandValidator.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| using FluentValidation; | ||
|
|
||
| namespace Eternelle.Modules.Catalog.Application.Templates.AddSupportedSection; | ||
|
|
||
| internal sealed class AddSupportedSectionCommandValidator : AbstractValidator<AddSupportedSectionCommand> | ||
| { | ||
| public AddSupportedSectionCommandValidator() | ||
| { | ||
| RuleFor(c => c.TemplateId).NotEmpty(); | ||
| RuleFor(c => c.SectionId).IsInEnum(); | ||
| RuleFor(c => c.DisplayOrder).GreaterThanOrEqualTo(0); | ||
| } | ||
| } |
12 changes: 12 additions & 0 deletions
12
...ernelle.Modules.Catalog.Application/Templates/AddTemplateTheme/AddTemplateThemeCommand.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| using Eternelle.Common.Application.Messaging; | ||
|
|
||
| namespace Eternelle.Modules.Catalog.Application.Templates.AddTemplateTheme; | ||
|
|
||
| public sealed record AddTemplateThemeCommand( | ||
| Guid TemplateId, | ||
| int ThemeIndex, | ||
| string Name, | ||
| IReadOnlyDictionary<string, string> Colors, | ||
| IReadOnlyDictionary<string, string> Typography, | ||
| IReadOnlyDictionary<string, string>? Textures, | ||
| bool IsDark) : ICommand; |
48 changes: 48 additions & 0 deletions
48
....Modules.Catalog.Application/Templates/AddTemplateTheme/AddTemplateThemeCommandHandler.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| using Eternelle.Common.Application.Caching; | ||
| using Eternelle.Common.Application.Clock; | ||
| using Eternelle.Common.Application.Messaging; | ||
| using Eternelle.Common.Domain; | ||
| using Eternelle.Modules.Catalog.Application.Abstractions.Data; | ||
| using Eternelle.Modules.Catalog.Domain.Templates; | ||
|
|
||
| namespace Eternelle.Modules.Catalog.Application.Templates.AddTemplateTheme; | ||
|
|
||
| internal sealed class AddTemplateThemeCommandHandler( | ||
| ITemplateRepository templateRepository, | ||
| IUnitOfWork unitOfWork, | ||
| ICacheService cacheService, | ||
| IDateTimeProvider dateTimeProvider) : ICommandHandler<AddTemplateThemeCommand> | ||
| { | ||
| public async Task<Result> Handle(AddTemplateThemeCommand command, CancellationToken cancellationToken) | ||
| { | ||
| Template? template = await templateRepository.GetAsync(new TemplateId(command.TemplateId), cancellationToken); | ||
| if (template is null) | ||
| { | ||
| return Result.Failure(TemplateErrors.NotFound(new TemplateId(command.TemplateId))); | ||
| } | ||
|
|
||
| Result<TemplateThemeName> nameResult = TemplateThemeName.Create(command.Name); | ||
| if (nameResult.IsFailure) | ||
| { | ||
| return Result.Failure(nameResult.Error); | ||
| } | ||
|
|
||
| var colors = new ThemeColors(command.Colors); | ||
| var typography = new ThemeTypography(command.Typography); | ||
| ThemeTextures? textures = command.Textures is null ? null : new ThemeTextures(command.Textures); | ||
|
|
||
| Result addResult = template.AddTheme( | ||
| command.ThemeIndex, nameResult.Value, colors, typography, textures, command.IsDark, dateTimeProvider.UtcNow); | ||
| if (addResult.IsFailure) | ||
| { | ||
| return addResult; | ||
| } | ||
|
|
||
| templateRepository.Update(template); | ||
| await unitOfWork.SaveChangesAsync(cancellationToken); | ||
|
|
||
| await cacheService.RemoveAsync(CatalogCacheKeys.TemplateById(command.TemplateId), cancellationToken); | ||
|
|
||
| return Result.Success(); | ||
| } | ||
| } |
16 changes: 16 additions & 0 deletions
16
...odules.Catalog.Application/Templates/AddTemplateTheme/AddTemplateThemeCommandValidator.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| using Eternelle.Modules.Catalog.Domain.Templates; | ||
| using FluentValidation; | ||
|
|
||
| namespace Eternelle.Modules.Catalog.Application.Templates.AddTemplateTheme; | ||
|
|
||
| internal sealed class AddTemplateThemeCommandValidator : AbstractValidator<AddTemplateThemeCommand> | ||
| { | ||
| public AddTemplateThemeCommandValidator() | ||
| { | ||
| RuleFor(c => c.TemplateId).NotEmpty(); | ||
| RuleFor(c => c.ThemeIndex).GreaterThanOrEqualTo(0); | ||
| RuleFor(c => c.Name).NotEmpty().MaximumLength(TemplateThemeName.MaxLength); | ||
| RuleFor(c => c.Colors).NotEmpty(); | ||
| RuleFor(c => c.Typography).NotEmpty(); | ||
| } | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| } | ||
18 changes: 18 additions & 0 deletions
18
src/Modules/Catalog/Eternelle.Modules.Catalog.Application/Templates/CatalogCacheKeys.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| using Eternelle.Modules.Catalog.Domain.Templates; | ||
|
|
||
| namespace Eternelle.Modules.Catalog.Application.Templates; | ||
|
|
||
| internal static class CatalogCacheKeys | ||
| { | ||
| public static string TemplateById(Guid templateId) => $"catalog:template:{templateId}"; | ||
|
|
||
| public static string TemplateList(TemplateTier? tier) => | ||
| tier is null ? "catalog:templates:all" : $"catalog:templates:{tier}"; | ||
|
|
||
| public static IReadOnlyList<string> AllTemplateListKeys() => | ||
| [ | ||
| TemplateList(null), | ||
| TemplateList(TemplateTier.FirstClass), | ||
| TemplateList(TemplateTier.Signature) | ||
| ]; | ||
| } |
11 changes: 11 additions & 0 deletions
11
...g/Eternelle.Modules.Catalog.Application/Templates/CreateTemplate/CreateTemplateCommand.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| using Eternelle.Common.Application.Messaging; | ||
| using Eternelle.Modules.Catalog.Domain.Templates; | ||
|
|
||
| namespace Eternelle.Modules.Catalog.Application.Templates.CreateTemplate; | ||
|
|
||
| public sealed record CreateTemplateCommand( | ||
| string Name, | ||
| string? Description, | ||
| TemplateTier Tier, | ||
| string? PreviewImageUrl, | ||
| IReadOnlyList<string>? Features) : ICommand<Guid>; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.