using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using WiBLL.ScanIdentifier; using static GB5Shared.GB5Constant.Constant; namespace WiSL.EndPoints.ScanIdentifier; // Backs the Print/List facilities' filterable, server-paged grid — these lists are genuinely // 50-100+ rows in practice (per the approved plan), never a client-rendered full table. public class GetScanIdentifierListPaged : BaseEndpoint> { private readonly IWiScanIdentifierBLL _bll; public GetScanIdentifierListPaged(IWiScanIdentifierBLL bll) => _bll = bll; public override void Configure() { Get("/ScanIdentifier/GetScanIdentifierListPaged"); AllowAnonymous(); } public record Parameters( [property: FromHeader] string Login, [property: QueryParam] string EntityType, // "" = all [property: QueryParam] int StatusFilter, // -1 All, 1 Active, 0 Inactive [property: QueryParam] string SearchTerm, [property: QueryParam] DateTime GeneratedFrom, [property: QueryParam] int Page, [property: QueryParam] int PageSize ); protected override string? GetCacheKey(Parameters req, LoginDTO login) => null; protected override async Task> ExecuteAsync(Parameters req, LoginDTO login, CancellationToken ct) { try { var result = await _bll.GetListPagedAsync( req.EntityType, req.StatusFilter, req.SearchTerm, req.GeneratedFrom, req.Page, req.PageSize, 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); } } }