using FastEndpoints; using FrameworkBLL.ReportHeaderMgmt; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using static GB5Shared.GB5Constant.Constant; namespace FrameworkSL.Endpoints.ReportHeader { public class GetReportHeaderList : BaseEndpoint> { private readonly IReportHeaderBLL _bll; public GetReportHeaderList(IReportHeaderBLL bll) => _bll = bll; public override void Configure() { Get("/ReportHeader/GetReportHeaderList"); AllowAnonymous(); } public record GetReportHeaderListParameters( [property: FromHeader] string Login ); protected override string? GetCacheKey(GetReportHeaderListParameters req, LoginDTO LoginDTO) => $"RH:List:{LoginDTO.ClientId}"; protected override async Task> ExecuteAsync( GetReportHeaderListParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var result = await _bll.GetReportHeaderList(LoginDTO!, ct); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse(result, CacheKeyLevel.CLIENT_LEVEL, LoginDTO); } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response.CreateExceptionError(ex, CacheKeyLevel.CLIENT_LEVEL, LoginDTO, ex.Message, 500); } } } }