feat(application): IProductTypeRepository + IProductQueryRepository stub + queries (PRD-001)
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
namespace SIGCM2.Application.Abstractions.Persistence;
|
||||
|
||||
/// <summary>
|
||||
/// PRD-002 handoff contract — query-only access to Product data needed by ProductType handlers.
|
||||
/// PRD-001 binds to NullProductQueryRepository (always returns false).
|
||||
/// PRD-002 binds to Dapper impl against dbo.Product (when that table exists).
|
||||
/// </summary>
|
||||
public interface IProductQueryRepository
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns true if at least one active Product with the given ProductTypeId exists.
|
||||
/// Used by DeactivateProductTypeCommandHandler to guard against orphaning active products.
|
||||
/// </summary>
|
||||
Task<bool> ExistsActiveByProductTypeAsync(int productTypeId, CancellationToken ct = default);
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
using SIGCM2.Application.Common;
|
||||
using SIGCM2.Domain.Entities;
|
||||
|
||||
namespace SIGCM2.Application.Abstractions.Persistence;
|
||||
|
||||
/// <summary>
|
||||
/// Write-side repository for ProductType.
|
||||
/// All reads needed by write handlers are included here.
|
||||
/// Query-side (for listing, filtering) uses GetPagedAsync with ProductTypesQuery.
|
||||
/// </summary>
|
||||
public interface IProductTypeRepository
|
||||
{
|
||||
/// <summary>Inserts a new ProductType and returns the DB-assigned Id.</summary>
|
||||
Task<int> AddAsync(ProductType productType, CancellationToken ct = default);
|
||||
|
||||
/// <summary>Returns the ProductType with the given Id, or null if not found.</summary>
|
||||
Task<ProductType?> GetByIdAsync(int id, CancellationToken ct = default);
|
||||
|
||||
/// <summary>Returns a paged result of ProductTypes matching the query.</summary>
|
||||
Task<PagedResult<ProductType>> GetPagedAsync(ProductTypesQuery query, CancellationToken ct = default);
|
||||
|
||||
/// <summary>Persists all changes to an existing ProductType row.</summary>
|
||||
Task UpdateAsync(ProductType productType, CancellationToken ct = default);
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if an active ProductType with the given nombre exists.
|
||||
/// Pass excludeId to skip the self-comparison during rename (update scenario).
|
||||
/// Case-insensitive — delegates to DB collation (SQL_Latin1_General_CP1_CI_AI).
|
||||
/// </summary>
|
||||
Task<bool> ExistsByNombreAsync(string nombre, int? excludeId = null, CancellationToken ct = default);
|
||||
}
|
||||
Reference in New Issue
Block a user