using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.DTO.Promotion; using GB5Shared.FastEndPoint; using GB5Shared.Promotion; using static GB5Shared.GB5Constant.Constant; namespace TMSSL.EndPoints.Promotion { // ============================================================ // ExportForPromotionBridge — internal service-to-service endpoint. Called only by // FrameworkBLL's RemoteHttpPromotionAdapter (running in FrameworkSL's own process), never by a // browser client, so the request carries a plain Login header the same way every other // internal cross-host call in this codebase already does (see JobEngineScheduleClient / the // "gb5-internal"/"eip-internal" named HttpClients in FrameworkSL/Program.cs) — no separate // machine credential, same trust model as any other GB5 endpoint reached over the internal // network. See GB5Shared/DTO/Promotion/PromotionBridgeDTOs.cs for why this exists. // ============================================================ public class ExportForPromotionBridge : BaseEndpoint> { private readonly IServiceProvider _ServiceProvider; public ExportForPromotionBridge(IServiceProvider serviceProvider) { _ServiceProvider = serviceProvider; } public override void Configure() { Post("/PromotionBridge/ExportForPromotion"); AllowAnonymous(); } public record Parameters( [property: FromBody] PromotionBridgeExportRequestDTO Body, [property: FromHeader] string Login ); protected override string? GetCacheKey(Parameters req, LoginDTO loginDTO) => null; protected override async Task> ExecuteAsync(Parameters req, LoginDTO loginDTO, CancellationToken ct) { try { var bundle = await PromotionBridgeService.ExportAsync( _ServiceProvider, req.Body.EntityTypeCode, req.Body.OriginEntityId, loginDTO, ct); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse(bundle, CacheKeyLevel.NOT_REQUIRED, loginDTO); } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response.CreateExceptionError(ex, CacheKeyLevel.NOT_REQUIRED, loginDTO, ex.Message, 500); } } } }