using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using Microsoft.AspNetCore.Mvc; using RecruitmentBLL.Application; using static GB5Shared.GB5Constant.Constant; namespace RecruitmentSL.EndPoints.Application { /// Thin passthrough to ECP's CommentThread feature (hosted by EngagementHost) via /// ApplicationBLL.GetApplicationComments / IEcpIntegrationService. public class GetApplicationComments : BaseEndpoint { private readonly IApplicationBLL _ApplicationBLL; public GetApplicationComments(IApplicationBLL applicationBLL) { _ApplicationBLL = applicationBLL; } public override void Configure() { Get("/Application/GetApplicationComments"); // Roles("HR", "Recruiter", "Interviewer") 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 GetApplicationCommentsParameters( [property: QueryParam] int ApplicationId, [property: FastEndpoints.FromHeader] string Login ); // Not cached: comments live entirely in ECP's own database (a different process) and // Recruitment has no hook to invalidate this key when ECP-side data changes — caching a // cross-host proxy read here would risk showing stale comment threads indefinitely. protected override string? GetCacheKey(GetApplicationCommentsParameters parameters, LoginDTO loginDTO) => null; protected override async Task> ExecuteAsync( GetApplicationCommentsParameters parameters, LoginDTO loginDTO, CancellationToken ct) { try { var result = await _ApplicationBLL .GetApplicationComments(parameters.ApplicationId, 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); } } } }