using FastEndpoints; using FrameworkBLL.AutoScheduler; using FrameworkDAL.DTO.AutoScheduler; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using static GB5Shared.GB5Constant.Constant; namespace FrameworkSL.Endpoints.JobDefine { // Handles both create (AutoSchedulerDTO.JobDefineId == 0) and update (JobDefineId != 0). // RunAs fields are written only on create — BLL enforces this, SL is unaware of the distinction. public class SaveJobDefine : BaseEndpoint> { private readonly IAutoSchedulerBLL _bll; public SaveJobDefine(IAutoSchedulerBLL bll) => _bll = bll; public override void Configure() { Post("/JobDefine/SaveJobDefine"); AllowAnonymous(); } public record Parameters( [property: FromHeader] string Login, [property: FromBody] AutoSchedulerDTO AutoSchedulerDTO ); protected override string? GetCacheKey(Parameters req, LoginDTO login) => null; protected override async Task> ExecuteAsync( Parameters req, LoginDTO login, CancellationToken ct) { var result = await _bll.SaveAutoScheduler(req.AutoSchedulerDTO, login); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse( result, CacheKeyLevel.NOT_REQUIRED, login); } } }