Add repositories, specifications, and multi-tenancy enhancements#84
Merged
samuelzedec merged 18 commits intomainfrom Sep 21, 2025
Merged
Add repositories, specifications, and multi-tenancy enhancements#84samuelzedec merged 18 commits intomainfrom
samuelzedec merged 18 commits intomainfrom
Conversation
… 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.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
IOrderRepository,IProductRepository, and their implementations for handlingOrderandProductentities.TenantEntity,OptionalTenantEntity, and updated all related entities.Consumesattributes and enriched token claims with company context for better multi-tenant handling.