using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using Microsoft.AspNetCore.Mvc; using RecruitmentBLL.JobProfileLibrary; using System.Threading; using static GB5Shared.GB5Constant.Constant; namespace RecruitmentSL.EndPoints.JobProfileLibrary { public class GetJobProfileLibrary : BaseEndpoint { private readonly IJobProfileLibraryBLL _JobProfileLibraryBLL; public GetJobProfileLibrary(IJobProfileLibraryBLL jobProfileLibraryBLL) { _JobProfileLibraryBLL = jobProfileLibraryBLL; } public override void Configure() { Get("/JobProfileLibrary/GetJobProfileLibrary"); // Roles("HR", "Recruiter", "Manager") throws 500 here — no host in this repo // configures AddAuthentication (HRFinanceHost included; see PayRollSL's // GetHRMSDashboard.cs for the same documented, repo-wide gap). AllowAnonymous // matches every other endpoint in this SL module today. AllowAnonymous(); } public record GetJobProfileLibraryParameters( [property: QueryParam] int JobProfileLibraryId, [property: FastEndpoints.FromHeader] string Login ); protected override string? GetCacheKey( GetJobProfileLibraryParameters parameters, LoginDTO loginDTO) // Reference/template content changes infrequently — CLIENT_LEVEL (not // NOT_REQUIRED) is appropriate here, unlike financial/transactional data. => KeyGenerator.KeyGeneration( parameters.JobProfileLibraryId, EntityConstant.OBJECTRECRUITMENTJOBPROFILELIBRARY, CacheKeyLevel.CLIENT_LEVEL, loginDTO); protected override async Task> ExecuteAsync( GetJobProfileLibraryParameters parameters, LoginDTO loginDTO, CancellationToken ct) { try { var result = await _JobProfileLibraryBLL .GetJobProfileLibrary(parameters.JobProfileLibraryId, 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); } } } }