using FastEndpoints;
using GB5Shared.DTO.Framework.Login;
using GB5Shared.DTO.Framework.ResponseStandard;
using GB5Shared.FastEndPoint;
using TCMSBLL.Interfaces;
using static GB5Shared.GB5Constant.Constant;
namespace TCMSSL.EndPoints.Export;
///
/// GET /TCMS/Export/ExportTCMSGherkin?moduleId={int}
/// Returns all active test cases for a module as a downloadable .feature file string.
/// No cache — always fresh export.
///
public class ExportTCMSGherkin : BaseEndpoint>
{
private readonly ITCMSImportBLL _Bll;
public ExportTCMSGherkin(ITCMSImportBLL bll) => _Bll = bll;
public override void Configure()
{
Get("/TCMS/Export/ExportTCMSGherkin");
AllowAnonymous();
}
public record Params(
[property: FromHeader] string Login,
[property: QueryParam] int ModuleId
);
protected override string? GetCacheKey(Params req, LoginDTO loginDTO) => null;
protected override async Task> ExecuteAsync(
Params req, LoginDTO loginDTO, CancellationToken ct)
{
var result = await _Bll.ExportGherkinAsync(req.ModuleId, loginDTO, ct);
return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse(
result, CacheKeyLevel.NOT_REQUIRED, loginDTO);
}
}