using FastEndpoints; using FrameworkBLL.OutboxMonitor; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using System; using System.Threading; using System.Threading.Tasks; using static FrameworkDAL.Constant.Constant; namespace FrameworkSL.Endpoints.OutboxMonitor { public class GetOutboxStatus : BaseEndpoint> { private readonly IOutboxMonitorBLL _bll; public GetOutboxStatus(IOutboxMonitorBLL bll) => _bll = bll; public override void Configure() { Get("/Outbox/GetOutboxStatus"); AllowAnonymous(); } public record Params( [property: FromHeader] string Login, [property: QueryParam] int? Status = null, // 0=Pending, 1=Published, 2=Failed, 3=Processing [property: QueryParam] int PageOffset = 0, [property: QueryParam] int PageSize = 50 ); protected override async Task> ExecuteAsync( Params req, LoginDTO login, CancellationToken ct) { try { var result = await _bll.GetStatusListAsync(req.Status, req.PageOffset, req.PageSize, login, ct); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse(result, CacheKeyLevel.UserLevel, login); } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response.CreateExceptionError(ex, CacheKeyLevel.UserLevel, login, ex.Message, 500); } } } }