using FastEndpoints; using FrameworkBLL.AutoScheduler; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using static GB5Shared.GB5Constant.Constant; namespace FrameworkSL.Endpoints.JobDefine { // Returns all jobs for the tenant (JobId = 0) or a single job's full admin detail // (JobId > 0 — for edit prefill in the wizard). Both paths return the same // JobDefineAdminDTO shape so the FE can reuse one model. public class GetJobDefine : BaseEndpoint> { private readonly IAutoSchedulerBLL _bll; public GetJobDefine(IAutoSchedulerBLL bll) => _bll = bll; public override void Configure() { Get("/JobDefine/GetJobDefine"); AllowAnonymous(); } public record Parameters( [property: FromHeader] string Login, [property: QueryParam] int JobId = 0 ); protected override string? GetCacheKey(Parameters req, LoginDTO login) => null; protected override async Task> ExecuteAsync( Parameters req, LoginDTO login, CancellationToken ct) { var result = await _bll.GetJobDefineAsync(req.JobId, login, ct); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse( result, CacheKeyLevel.NOT_REQUIRED, login); } } }