using ComplianceBLL.GSPConfig; using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using static GB5Shared.GB5Constant.Constant; namespace ComplianceSL.Endpoints.GSPConfig; public class GetGSP : BaseEndpoint> { private readonly IGSPConfigBLL _bll; public GetGSP(IGSPConfigBLL bll) => _bll = bll; public override void Configure() { Get("/GSP/GetGSP"); AllowAnonymous(); } public record GetGSPParameters( [property: FromHeader] string Login, [property: QueryParam] int GSPConfigId ); protected override string? GetCacheKey(GetGSPParameters req, LoginDTO login) => $"GSPCONFIG:{login.ClientId}:{req.GSPConfigId}"; protected override async Task> ExecuteAsync(GetGSPParameters req, LoginDTO login, CancellationToken ct) { try { var result = await _bll.GetGSPConfig(req.GSPConfigId, login, ct); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse(result, CacheKeyLevel.CLIENT_LEVEL, login); } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response.CreateExceptionError(ex, CacheKeyLevel.CLIENT_LEVEL, login, ex.Message, 500); } } }