Yaojia Wang
|
d2ed21873e
|
refactor(backend): Remove ITenantContext from Command/Query Handlers
Fix architectural issue where tenant isolation logic was incorrectly placed
in the Application layer (Handlers) instead of the Infrastructure layer
(DbContext/Repository).
Changes:
- Removed ITenantContext injection from 12 Command/Query Handlers
- Removed manual tenant verification code from all handlers
- Tenant isolation now handled exclusively by Global Query Filters in PMDbContext
- Handlers now focus purely on business logic, not cross-cutting concerns
Architecture Benefits:
- Proper separation of concerns (Handler = business logic, DbContext = tenant filtering)
- Eliminates code duplication across handlers
- Follows Repository pattern correctly
- Single Responsibility Principle compliance
- Cleaner, more maintainable code
Affected Handlers:
- CreateEpicCommandHandler
- UpdateEpicCommandHandler
- CreateStoryCommandHandler
- UpdateStoryCommandHandler
- AssignStoryCommandHandler
- DeleteStoryCommandHandler
- CreateTaskCommandHandler
- UpdateTaskCommandHandler
- AssignTaskCommandHandler
- DeleteTaskCommandHandler
- UpdateTaskStatusCommandHandler
- GetEpicByIdQueryHandler
Technical Notes:
- PMDbContext already has Global Query Filters configured correctly
- Project aggregate passes TenantId when creating child entities
- Repository queries automatically filtered by tenant via EF Core filters
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
|
2025-11-04 17:15:43 +01:00 |
|