using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using RecruitmentBLL.Career; using static GB5Shared.GB5Constant.Constant; namespace RecruitmentSL.EndPoints.Career { // Public career-site job detail. RecruitmentBLL.Career.CareerBLL only ever resolves a // Published(=5)+Active(=1) requisition for the tenant, and rejects (with a clear, // deliberately generic error — see CareerQB.GET_PUBLISHED_JOB_DETAIL's comment) an // unknown id and a "exists but not published" id identically. public class GetPublishedJobDetail : BaseEndpoint> { private readonly ICareerBLL _CareerBLL; public GetPublishedJobDetail(ICareerBLL careerBLL) { _CareerBLL = careerBLL; } public override void Configure() { Get("/Career/GetPublishedJobDetail"); AllowAnonymous(); } public record GetPublishedJobDetailParameters( [property: QueryParam] int JobRequisitionId, [property: FastEndpoints.FromHeader] string Login ); // Cached at CLIENT_LEVEL keyed by JobRequisitionId — same precedent as // JobRequisition/GetJobRequisition.cs (single-record GETs in this module are cached; // list/select-list GETs are not — see GetPublishedJobs.cs's GetCacheKey comment). protected override string? GetCacheKey( GetPublishedJobDetailParameters req, LoginDTO login) => KeyGenerator.KeyGeneration( req.JobRequisitionId, EntityConstant.OBJECTRECRUITMENTJOBREQUISITION, CacheKeyLevel.CLIENT_LEVEL, login); protected override async Task> ExecuteAsync( GetPublishedJobDetailParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var result = await _CareerBLL .GetPublishedJobDetail(req.JobRequisitionId, LoginDTO!, ct); return await GB5Shared.ResponseStandard.Response .CreateSuccessResponse( result, CacheKeyLevel.CLIENT_LEVEL, LoginDTO); } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response .CreateExceptionError( ex, CacheKeyLevel.CLIENT_LEVEL, LoginDTO, ex.Message, 500); } } } }