using FastEndpoints; using FrameworkBLL.ReportViewer; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using static GB5Shared.GB5Constant.Constant; namespace FrameworkSL.Endpoints.ReportViewer { public class GetReportViewByMenu : BaseEndpoint> { private readonly IReportViewBLL _bll; public GetReportViewByMenu(IReportViewBLL bll) => _bll = bll; public override void Configure() { Get("/ReportView/GetReportViewByMenu"); AllowAnonymous(); } public record GetReportViewByMenuParameters( [property: FromHeader] string Login, [property: QueryParam] int ReportId, [property: QueryParam] int MenuId ); //protected override string? GetCacheKey(GetReportViewByMenuParameters req, LoginDTO LoginDTO) // => $"RV:Menu:{LoginDTO.ClientId}:{req.ReportId}:{req.MenuId}"; protected override async Task> ExecuteAsync( GetReportViewByMenuParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var result = await _bll.GetReportViewByMenu(req.ReportId, req.MenuId, LoginDTO!, ct); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse(result, CacheKeyLevel.CLIENT_LEVEL, LoginDTO); } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response.CreateExceptionError(ex, CacheKeyLevel.CLIENT_LEVEL, LoginDTO, ex.Message, 500); } } } }