using FastEndpoints;
using FrameworkBLL.MetaReport;
using GB5Shared.DTO.Framework.Login;
using GB5Shared.DTO.Framework.ResponseStandard;
using GB5Shared.FastEndPoint;
using static GB5Shared.GB5Constant.Constant;
namespace FrameworkSL.Endpoints.MetaReport
{
/// Full aggregate (row + Variants + Aspects + each Aspect's Options with their
/// ApplicableVariantIds) — consumed by both the authoring screen and, once wired,
/// MetaReportLoaderService in place of the static trial-balance.meta.json file it reads
/// today. See Docs/MetaReport_Guide.md.
public class GetMetaReport : BaseEndpoint>
{
private readonly IMetaReportBLL _metaReportBLL;
public GetMetaReport(IMetaReportBLL metaReportBLL) => _metaReportBLL = metaReportBLL;
public override void Configure()
{
Get("/MetaReport/GetMetaReport");
AllowAnonymous();
}
public record GetMetaReportParameters(
[property: FromHeader] string Login,
[property: QueryParam] int MetaReportId
);
protected override string? GetCacheKey(GetMetaReportParameters req, LoginDTO loginDTO)
=> KeyGenerator.KeyGeneration(req.MetaReportId, EntityConstant.OBJECTMETAREPORT, CacheKeyLevel.CLIENT_LEVEL, loginDTO);
protected override async Task> ExecuteAsync(
GetMetaReportParameters req, LoginDTO loginDTO, CancellationToken ct)
{
var result = await _metaReportBLL.GetMetaReport(req.MetaReportId, loginDTO, ct);
return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse(result, CacheKeyLevel.CLIENT_LEVEL, loginDTO);
}
}
}