using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using SwBLL.OfflineRollout; using static GB5Shared.GB5Constant.Constant; using GB5Shared.Authorization; namespace SwSL.EndPoints.OfflineRollout; //[MenuRights("SWCLIENTDBKEY", RightOperation.View)] public class ExportOfflinePackage : BaseEndpoint> { private readonly IOfflineRolloutExportBLL _bll; public ExportOfflinePackage(IOfflineRolloutExportBLL bll) => _bll = bll; public override void Configure() { Get("/OfflineRollout/ExportOfflinePackage"); AllowAnonymous(); } public record Parameters( [property: FromHeader] string Login, [property: QueryParam] int ClientDbId, [property: QueryParam] int PackageId); protected override string? GetCacheKey(Parameters req, LoginDTO loginDTO) => null; // Returns the encrypted package as a Base64 string in Body — this deployment's own // ResponseStandardDTO convention wraps every payload shape (JSON, plain messages) the same // way; a raw binary/file-download response would be the first of its kind in this module and // isn't needed for a payload this small (a serialized script bundle, tens of KB to a few MB). // The caller (an admin screen, or a scripted download) Base64-decodes Body into the real // .gbrollout file before handing it to a customer. protected override async Task> ExecuteAsync( Parameters req, LoginDTO loginDTO, CancellationToken ct) { var encrypted = await _bll.ExportOfflinePackageAsync(req.ClientDbId, req.PackageId, loginDTO, ct); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse( Convert.ToBase64String(encrypted), CacheKeyLevel.NOT_REQUIRED, loginDTO); } }