using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using QMSBLL.PcsCard; using static GB5Shared.GB5Constant.Constant; namespace QMSSL.EndPoints.PcsCard; public class GetPcsCardList : BaseEndpoint> { private readonly IPcsCardBLL _bll; public GetPcsCardList(IPcsCardBLL bll) => _bll = bll; public override void Configure() { Get("/PcsCard/GetPcsCardList"); AllowAnonymous(); } public record Params( [property: FromHeader] string Login, [property: QueryParam] int OuId, [property: QueryParam] int PeriodId, [property: QueryParam] byte? OverallStatus, [property: QueryParam] int? CustomerId, [property: QueryParam] int? ItemId, [property: QueryParam] string? VariantCode, [property: QueryParam] string? Search, [property: QueryParam] DateTime? PlannedEndFrom, [property: QueryParam] DateTime? PlannedEndTo, [property: QueryParam] string SortBy = "CARDNO", [property: QueryParam] string SortDir = "ASC", [property: QueryParam] int PageOffset = 0, [property: QueryParam] int PageSize = 20); protected override string? GetCacheKey(Params req, LoginDTO login) => KeyGenerator.KeyGeneration( req, req.PageOffset, CacheKeyLevel.CLIENT_LEVEL, login); protected override async Task> ExecuteAsync( Params req, LoginDTO login, CancellationToken ct) { try { var (rows, total) = await _bll.GetPcsCardListAsync( req.OuId, req.PeriodId, req.OverallStatus, req.CustomerId, req.ItemId, req.VariantCode, req.Search, req.PlannedEndFrom, req.PlannedEndTo, req.SortBy, req.SortDir, req.PageOffset, req.PageSize, login, ct); return await GB5Shared.ResponseStandard.Response .CreateSuccessResponse(new { Rows = rows, TotalCount = total }, CacheKeyLevel.CLIENT_LEVEL, login); } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response .CreateExceptionError(ex, CacheKeyLevel.CLIENT_LEVEL, login, ex.Message, 500); } } }