using FastEndpoints; using GB5Shared.DTO.Framework.Criteria; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using QMSBLL.Matrix; using static GB5Shared.GB5Constant.Constant; namespace QMSSL.EndPoints.Matrix; public class GetGeneratedSets : BaseEndpoint> { private readonly IMatrixBLL _bll; public GetGeneratedSets(IMatrixBLL bll) => _bll = bll; public override void Configure() { Post("/Matrix/GetGeneratedSets"); AllowAnonymous(); Description(x => x .WithTags("Matrix") .WithSummary("Get Generated Sets") .WithDescription("Backs the old Matrix Planner's SetFrom/SetTo picklist. Caller sends a " + "CriteriaDTO with an \"AllotedAllocationId\" field. Returns exactly which set numbers " + "have actually been generated via SaveSetSerialGenration for this allocation (e.g. " + "[1,2,3,4,5] if 5 sets were created), plus SetFrom/SetTo bounds (never 0 — the real " + "minimum generated set, normally 1) — fully dynamic, parsed from real SET-level TLOT " + "rows, no set count or range hardcoded. Use these bounds to restrict SetFrom/SetTo to " + "real sets instead of an arbitrary typed range before calling ExplodeBOM or SaveMatrix.")); } public record Params( [property: FromHeader] string Login, [property: FromBody] CriteriaDTO CriteriaDTO); protected override string? GetCacheKey(Params req, LoginDTO login) => null; protected override async Task> ExecuteAsync( Params req, LoginDTO login, CancellationToken ct) { try { var result = await _bll.GetGeneratedSetsAsync(req.CriteriaDTO, login, ct); return await GB5Shared.ResponseStandard.Response .CreateSuccessResponse(result, CacheKeyLevel.NOT_REQUIRED, login); } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response .CreateExceptionError( ex, CacheKeyLevel.NOT_REQUIRED, login, ex.Message, 500); } } }