Skip to content

Add repositories, specifications, and multi-tenancy enhancements#84

Merged
samuelzedec merged 18 commits intomainfrom
develop
Sep 21, 2025
Merged

Add repositories, specifications, and multi-tenancy enhancements#84
samuelzedec merged 18 commits intomainfrom
develop

Conversation

@samuelzedec
Copy link
Owner

  • Introduced repository pattern with IOrderRepository, IProductRepository, and their implementations for handling Order and Product entities.
  • Enhanced filtering capabilities using specifications and applied them to domain and application layers. Added comprehensive unit tests.
  • Added multi-tenancy support through new TenantEntity, OptionalTenantEntity, and updated all related entities.
  • Improved API definitions with Consumes attributes and enriched token claims with company context for better multi-tenant handling.
  • Refactored Docker configurations, removed redundant files,

… logic

- Consolidated user retrieval logic into a reusable `GetBaseUserQuery` property to enhance maintainability and reduce duplication.
- Replaced `userManager` methods in `AuthService` with streamlined query-based logic for `FindByIdAsync`, `FindByEmailAsync`, `FindByUserNameAsync`, and `FindByPhoneAsync`.
- Added regions to organize properties, methods, and helpers for better structure.
…rService`

- Added `<remarks>` to indicate proper usage of `ICurrentUserService` in authenticated contexts.
- Introduced `GetCompanyId` method to retrieve the company identifier for the current user.
- Removed redundant modifiers from interface method definitions for cleaner syntax.
…g in auth flows

- Included `UserDomain` in `UserDetailsDTO` for enriched token claims management.
- Replaced nullable checks for `currentUserService.GetUserId` with direct calls in logout and refresh token handlers.
- Removed redundant tests for null user ID, simplifying exception testing in command and query handlers.
- Introduced `ProductRepository` and `OrderRepository` to IoC container for better modularity.
- Added company context to JWT claims for improved multi-tenancy support.
- Updated Serilog config to exclude errors from general log files, improving log clarity.
…mpose.yml` and scripts

- Deleted `infra/docker/Dockerfile.dev`, consolidating stages into simplified configuration.
- Updated `docker-compose.yml` to reference `Dockerfile.dev` directly in the root directory.
- Fixed incorrect path in `generate-certificates.sh`.
- Adjusted README to improve formatting and add default user credentials.
- Added `IOptionalTenantEntity` and `ITenantEntity` interfaces for multi-tenant support.
- Implemented `OptionalTenantEntity` and `TenantEntity` abstract classes to define base behavior.
…support

- Replaced `BaseEntity` inheritance with `TenantEntity` in `Product`, `ProductCategory`, `Invitation`, and `Order`.
- Updated `User` to inherit from `OptionalTenantEntity`.
- Removed `CompanyId` properties from affected entities to align with new tenant-based structure.
- Introduced `Categories` permission group in `PermissionsSettings`.
- Updated `ApplicationRoleClaimSeeder` with category permission claims.
- Added category permissions to `ApplicationPermissionSeeder` with descriptions and IDs.
…derExecuting` method

- Introduced synchronous `ReaderExecuting` override to complement `ReaderExecutingAsync`.
- Applied `ApplyCaseInsensitive` logic to both synchronous and asynchronous execution paths.
… contract definitions

- Added `[Consumes("application/json")]` attribute to `UserController`, `CompanyController`, and `AuthController`.
- Introduced `Dockerfile.dev` with build, migration, and runtime stages.
- Configured necessary dependencies for .NET 9.0 SDK and ASP.NET runtime.
- Added support for migrations and TLS certificate generation scripts.
- Introduced `AddCategoriesSeeders` migration to seed category permissions.
- Inserted category permissions into `application_permissions` table with predefined IDs.
- Generated designer file for model snapshot updates.
- Added `Specification<T>` abstraction with logical operators (`And`, `Or`, `Not`) for composing business rules.
- Implemented `AndSpecification`, `OrSpecification`, and `NotSpecification` for combining predicates.
- Created `ReplacerParameter` utility to handle parameter replacements in expressions.
- Added `SanitizeStatic` and `ValidateLength` static methods to `IDocumentValidator` for reusable logic.
- Updated `CnpjValidator` and `CpfValidator` to utilize the new `IDocumentValidator` methods.
- Renamed `Length` constants to `ExpectedLength` for improved readability.
- Eliminated unnecessary blank lines and adjusted indentation across all `.csproj` files.
- Standardized formatting to ensure cleaner and more readable project structure files.
- Introduced specifications for `Company` and `User` entities, including `Id`, `Email`, `Phone`, and `TaxId` validations.
- Added tenant-related specifications: `TenantSpecification`, `OptionalTenantSpecification`, and `NoTenantSpecification`.
- Implemented comprehensive unit tests for all specifications to ensure correctness.
…in and application layers

- Replaced `Expression<Func<T, bool>>` with `Specification<T>` for repository methods (`GetSingleAsync`, `ExistsAsync`, `Query`) to enhance query composability.
- Updated handlers and services to leverage new specification-based logic.
- Added related specifications for `Company` and `User` entities with adjustments to existing tests.
- Renamed `invitations` and `application_permissions` tables to `invitation` and `application_permission`.
- Updated primary keys and unique constraints for consistency with naming conventions.
- Generated migration and updated model snapshot to reflect changes.
…nd orders

- Introduced `IOrderRepository` and `IProductRepository` interfaces for managing `Order` and `Product` entities.
- Added `OrderRepository` and `ProductRepository` implementations for persistence operations.
- Implemented `ProductByCategoryIdSpecification` for filtering products by category, and included corresponding unit tests.
- Enhanced query functionality with `IQueryableExtension` and `SpecificationExtension` for applying specifications and includes in queries.
- Introduced `Orders` and `Products` properties to `IUnitOfWork` interface.
- Implemented `OrderRepository` and `ProductRepository` instantiation in `UnitOfWork` class.
@samuelzedec samuelzedec merged commit 12e79cf into main Sep 21, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant