using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using SwBLL.ChangeRequest; using static GB5Shared.GB5Constant.Constant; using GB5Shared.Authorization; namespace SwSL.EndPoints.ChangeRequest; // Background alternative to ExecuteChangeRequest.cs (tracker §37) — for a large batch (e.g. a // full base-schema baseline, proven live in §36.13 to run for several minutes), queues the CR for // ChangeRequestExecutionWorkerJob's own Quartz timer instead of running inline on this HTTP // request's own CancellationToken, which an ordinary client-side timeout would otherwise abort // mid-batch with no way to resume. ExecuteChangeRequest.cs itself is untouched — still the right // call for small/interactive CRs that finish in well under a request timeout. //[MenuRights("SWCHREQ", RightOperation.Update)] public class QueueChangeRequestExecution : BaseEndpoint> { private readonly IChangeRequestBLL _bll; public QueueChangeRequestExecution(IChangeRequestBLL bll) => _bll = bll; public override void Configure() { Post("/ChangeRequest/QueueChangeRequestExecution"); AllowAnonymous(); } public record Parameters( [property: FromHeader] string Login, [property: QueryParam] int ChangeRequestId); protected override string? GetCacheKey(Parameters req, LoginDTO loginDTO) => null; protected override async Task> ExecuteAsync( Parameters req, LoginDTO loginDTO, CancellationToken ct) { var result = await _bll.QueueExecutionAsync(req.ChangeRequestId, loginDTO, ct); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse( result, CacheKeyLevel.NOT_REQUIRED, loginDTO); } }