using FastEndpoints; using GB5Shared.DTO.Framework.Criteria; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using Microsoft.AspNetCore.Mvc; using RecruitmentBLL.JobProfileLibrary; using static GB5Shared.GB5Constant.Constant; namespace RecruitmentSL.EndPoints.JobProfileLibrary { public class GetSelectListJobProfileLibrary : BaseEndpoint< GetSelectListJobProfileLibrary.GetSelectListJobProfileLibraryParameters, ResponseStandardDTO> { private readonly IJobProfileLibraryBLL _JobProfileLibraryBLL; public GetSelectListJobProfileLibrary(IJobProfileLibraryBLL jobProfileLibraryBLL) { _JobProfileLibraryBLL = jobProfileLibraryBLL; } public override void Configure() { Post("/JobProfileLibrary/GetSelectListJobProfileLibrary"); // 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(); } // Browse-screen list: CriteriaDTO.SearchKeyword is matched (prefix LIKE) against both // ROLETITLE and INDUSTRYTAG in JobProfileLibraryQB.GET_SELECTLIST_JOBPROFILELIBRARY. public record GetSelectListJobProfileLibraryParameters( [property: FastEndpoints.FromHeader] string Login, [property: FastEndpoints.FromBody] CriteriaDTO CriteriaDTO ); protected override string? GetCacheKey( GetSelectListJobProfileLibraryParameters parameters, LoginDTO loginDTO) // Reference/template content changes infrequently — CLIENT_LEVEL (not // NOT_REQUIRED) is appropriate here, unlike financial/transactional data. => KeyGenerator.KeyGeneration( parameters.CriteriaDTO?.SearchKeyword ?? string.Empty, EntityConstant.OBJECTRECRUITMENTJOBPROFILELIBRARY, CacheKeyLevel.CLIENT_LEVEL, loginDTO); protected override async Task> ExecuteAsync( GetSelectListJobProfileLibraryParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var result = await _JobProfileLibraryBLL .GetSelectListJobProfileLibrary(req.CriteriaDTO, 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); } } } }