using GB5Shared.DTO.Framework.Login; using GB5Shared.ListQuery; using GB5Shared.QueryExecutor; using QMSDAL.DTO; namespace QMSDAL.Query.Matrix { // ── Criteria ─────────────────────────────────────────────────────────────── // Holds all filter, sort, and paging inputs for the matrix list. // AllocationId is mandatory — validated by MatrixListGuard before execution. // ────────────────────────────────────────────────────────────────────────── public sealed class MatrixListCriteria : IListCriteria { // ── Paging ───────────────────────────────────────────────────────────── public int PageSize { get; init; } = 20; public int PageOffset { get; init; } = 0; // ── Cursor (optional — used when CursorId-based paging is preferred) ── public int? CursorId { get; init; } public bool SkipCount { get; init; } // ── Sorting ──────────────────────────────────────────────────────────── public string? SortBy { get; init; } public bool SortDesc { get; init; } public string[]? SortFields { get; init; } // ── Search ───────────────────────────────────────────────────────────── public string? SearchText { get; init; } // ── Mandatory filter ─────────────────────────────────────────────────── // Guards in MatrixListGuard and BuildMatrixList both enforce AllocationId > 0. public int AllocationId { get; init; } // ── Optional filters ─────────────────────────────────────────────────── public byte? StatusFilter { get; init; } // 0=Draft 1=Active 2=Superseded 3=Deleted public byte? ModeFilter { get; init; } // 0=Product 1=FGItem 2=OpenMix // ── Tenant ───────────────────────────────────────────────────────────── // Informational — actual TenantId used in SQL always comes from LoginDTO. public int TenantId { get; init; } // ── OUId (retained for interface compatibility, not used in matrix SQL) ─ public int? OUId { get; init; } } // ── Query ────────────────────────────────────────────────────────────────── // This class is a criteria carrier only. // SQL is built by MatrixListQB (IQueryBuilder) and executed by IListHandler. // Do NOT put inline SQL or _qe calls here. // ────────────────────────────────────────────────────────────────────────── [QuerySource(QueryIntent.Transactional)] public sealed class MatrixListQuery : IListQuery { // ── Criteria carrier ─────────────────────────────────────────────────── public MatrixListCriteria Criteria { get; private set; } = default!; public void SetCriteria(MatrixListCriteria criteria) { ArgumentNullException.ThrowIfNull(criteria); Criteria = criteria; } } }