using FastEndpoints; using FrameworkBLL.GOP; using GB5Shared.DTO.Framework.Login; using GB5Shared.FastEndPoint; using static GB5Shared.GB5Constant.Constant; namespace FrameworkSL.Endpoints.GOP.Execution { public class GetGopExecutionList : BaseEndpoint> { private readonly IGopExecutionMonitorBLL _Bll; public GetGopExecutionList(IGopExecutionMonitorBLL bll) => _Bll = bll; public override void Configure() { Get("/GOP/GetGopExecutionList"); AllowAnonymous(); } public record GetGopExecutionListParameters( [property: QueryParam] string? Status, [property: QueryParam] int Page, [property: QueryParam] int PageSize, [property: FromHeader] string Login ); // Execution lists are highly volatile — do not cache. protected override string? GetCacheKey(GetGopExecutionListParameters req, LoginDTO loginDTO) => null; protected override async Task> ExecuteAsync( GetGopExecutionListParameters req, LoginDTO loginDTO, CancellationToken ct) { try { var result = await _Bll.GetExecutionList( req.Status, req.Page > 0 ? req.Page : 1, req.PageSize > 0 ? req.PageSize : 50, loginDTO, ct); return await GB5Shared.ResponseStandard.Response .CreateSuccessResponse(result, CacheKeyLevel.NOT_REQUIRED, loginDTO); } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response .CreateExceptionError(ex, CacheKeyLevel.NOT_REQUIRED, loginDTO, ex.Message, 500); } } } }