Refactor messaging system to utilize LiteCqrs library
- Replaced instances of the previous messaging system with LiteCqrs across various application components, enhancing the CQRS implementation. - Updated dependency injection to register LiteCqrs services and behaviors, streamlining command and query handling. - Adjusted multiple command and query handlers to align with the new messaging framework, ensuring consistent functionality and improved maintainability. - Added LiteCqrs package reference in the project file for better dependency management.
This commit is contained in:
+11
-5
@@ -4,11 +4,17 @@
|
||||
|
||||
- **Платформа**: .NET 10, ASP.NET Core Web API (Minimal API).
|
||||
- **Архитектура**: Clean Architecture, 4 проекта — `Domain / Application / Infrastructure / Api`.
|
||||
- **CQRS**: собственный тонкий диспетчер (`ISender`), без MediatR. `ISender.Send()` резолвит
|
||||
`ICommandHandler<,>`/`IQueryHandler<,>` из DI и прогоняет через `IPipelineBehavior<,>`:
|
||||
`ValidationBehavior` (FluentValidation), `LoggingBehavior`, `UnitOfWorkBehavior` (транзакция +
|
||||
`SaveChangesAsync` на команду). Авторизация проверяется на уровне эндпоинта
|
||||
(`RequireAuthorization(...)`), более тонкие проверки (владение, активация) — в хендлере.
|
||||
- **CQRS**: через [`LiteCqrs.Net`](https://github.com/mrleo1nid/LiteCqrs.Net) — собственную лёгкую
|
||||
CQRS-библиотеку (сосед-репозиторий, на время разработки подключён `ProjectReference`'ом; ещё не
|
||||
опубликован в NuGet), альтернативу MediatR с явным разделением Command/Query. `ISender.Send()`
|
||||
резолвит `ICommandHandler<,>`/`IQueryHandler<,>` из DI (dynamic-free кэшированный диспетчер) и
|
||||
прогоняет через `IPipelineBehavior<,>`: `LoggingBehavior` (готовый, из `LiteCqrs.Behaviors`),
|
||||
`ValidationBehavior` (FluentValidation, свой), `RequireActivationBehavior` (свой),
|
||||
`UnitOfWorkBehavior` (транзакция + `SaveChangesAsync` на команду, свой) — регистрация через
|
||||
`AddLiteCqrs(...)` в `PnvPanel.Application/DependencyInjection.cs`. Библиотека также даёт
|
||||
Notifications/pub-sub, exception behaviors и streaming-запросы — PnvPanel их пока не использует.
|
||||
Авторизация проверяется на уровне эндпоинта (`RequireAuthorization(...)`), более тонкие проверки
|
||||
(владение, активация) — в хендлере.
|
||||
- **Валидация**: FluentValidation, подключается через `ValidationBehavior` (не для каждой команды —
|
||||
только там, где есть что проверить помимо типов).
|
||||
- **Маппинг**: вручную, статический метод `XxxDto.FromDomain(entity)` на самом DTO.
|
||||
|
||||
Reference in New Issue
Block a user