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 list. Read-only, tightly scoped: RecruitmentBLL.Career.CareerBLL // only ever returns Published(=5)+Active(=1) requisitions for the tenant, and only the // public-appropriate PublicJobPostingDTO shape — never the internal JobRequisitionDTO. public class GetPublishedJobs : BaseEndpoint> { private readonly ICareerBLL _CareerBLL; public GetPublishedJobs(ICareerBLL careerBLL) { _CareerBLL = careerBLL; } public override void Configure() { Get("/Career/GetPublishedJobs"); // Genuinely public — no host in this repo configures AddAuthentication (see // PayRollSL's GetHRMSDashboard.cs for the repo-wide gap), and this endpoint is // deliberately intended for anonymous career-site visitors either way. AllowAnonymous(); } public record GetPublishedJobsParameters( [property: QueryParam] int FirstNumber, [property: QueryParam] int MaxResult, [property: FastEndpoints.FromHeader] string Login ); // Not cached — same precedent as GetSelectListJobRequisition (no GetCacheKey override) // in this same module: a paged public list is exactly the shape that goes stale under // CLIENT_LEVEL caching once a requisition is newly Published/Closed, since a single // JobRequisition save only invalidates that one requisition's own cache key, never a // list's. Leaving this uncached keeps the career site's "what's open right now" list // always live instead of trading correctness for a short TTL. protected override string? GetCacheKey(GetPublishedJobsParameters req, LoginDTO login) => null; protected override async Task> ExecuteAsync( GetPublishedJobsParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var result = await _CareerBLL .GetPublishedJobs(req.FirstNumber, req.MaxResult, LoginDTO!, ct); return await GB5Shared.ResponseStandard.Response .CreateSuccessResponse( result, CacheKeyLevel.NOT_REQUIRED, LoginDTO); } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response .CreateExceptionError( ex, CacheKeyLevel.NOT_REQUIRED, LoginDTO, ex.Message, 500); } } } }