using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using PayRollBLL.Job; using static GB5Shared.GB5Constant.Constant; namespace PayRollSL.EndPoints.Job { public class GetJob : BaseEndpoint> { private readonly IJobBLL _JobBLL; public GetJob(IJobBLL jobBLL) { _JobBLL = jobBLL; } public override void Configure() { Get("/Job/GetJob"); AllowAnonymous(); } public record GetJobParameters( [property: FromHeader] string Login, [property: QueryParam] int JobId ); protected override string? GetCacheKey(GetJobParameters req, LoginDTO loginDTO) { try { return KeyGenerator.KeyGeneration(req.JobId, EntityConstant.OBJECTJOB, CacheKeyLevel.USER_LEVEL, loginDTO); } catch (Exception) { throw; } } protected override async Task> ExecuteAsync( GetJobParameters req, LoginDTO loginDTO, CancellationToken ct) { try { var result = await _JobBLL.GetJob(req.JobId, loginDTO); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse( result, CacheKeyLevel.USER_LEVEL, loginDTO); } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response.CreateExceptionError( ex, CacheKeyLevel.USER_LEVEL, loginDTO, ex.Message, 500); } } } }