using EAIAdminBLL.EAIExecution; using EAIAdminDAL.DTO; using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using static GB5Shared.GB5Constant.Constant; namespace EAIAdminSL.Endpoints { // Replaces the Report Viewer's "AI Co-Analyst" direct call to 217.217.249.121:8002 (no auth, // no ReportId/ReportCode). AllowAnonymous() + server-derived login.ClientId/UserId — same // platform-wide pattern as every other GB5 endpoint — so gbEAI's taiexecution log gets real // tenant/user attribution for report analysis for the first time. public class AnalyzeReport : BaseEndpoint> { private readonly IEAIExecutionBLL _bll; public AnalyzeReport(IEAIExecutionBLL bll) => _bll = bll; public override void Configure() { Post("/EAIAdmin/AnalyzeReport"); AllowAnonymous(); Description(b => b.WithTags("EAIAdmin")); } protected override string? GetCacheKey(Parameters req, LoginDTO login) => null; protected override async Task> ExecuteAsync( Parameters req, LoginDTO login, CancellationToken ct) { var dto = req.Body ?? throw new ArgumentNullException(nameof(req.Body)); var result = await _bll.AnalyzeReportAsync(dto, login, ct).ConfigureAwait(false); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse( result, CacheKeyLevel.NOT_REQUIRED, login); } public record Parameters( [property: FromHeader] string? Login, [property: FromBody] EAIAnalyzeReportRequestDTO? Body); } }