using FastEndpoints; using FrameworkBLL.DiagnosticsCenter; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using static FrameworkDAL.Constant.Constant; namespace FrameworkSL.Endpoints.DiagnosticsCenter; public class GetRecentErrors : BaseEndpoint> { private readonly IDiagnosticsCenterBLL _bll; public GetRecentErrors(IDiagnosticsCenterBLL bll) => _bll = bll; public override void Configure() { Get("/DiagnosticsCenter/GetRecentErrors"); AllowAnonymous(); } protected override string? GetCacheKey(Parameters req, LoginDTO login) => null; protected override async Task> ExecuteAsync( Parameters req, LoginDTO login, CancellationToken ct) { var result = await _bll.GetRecentErrorsAsync(req.TopN, req.HoursBack, login, ct) .ConfigureAwait(false); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse( result, CacheKeyLevel.NotRequired, login); } public record Parameters( [property: FromHeader] string Login, [property: QueryParam] int TopN = 20, [property: QueryParam] int HoursBack = 24); }