using FastEndpoints; using FrameworkBLL.Menu; using GB5Shared.DTO.Framework.Criteria; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using static GB5Shared.GB5Constant.Constant; namespace FrameworkSL.Endpoints.Menu { public sealed class GetMenuListBasedMenuSetForTree : BaseEndpoint { private readonly IMenuBLL _menuBLL; public GetMenuListBasedMenuSetForTree(IMenuBLL menuBLL) { _menuBLL = menuBLL; } public override void Configure() { Post("/Menu/GetMenuListBasedMenuSetForTree"); AllowAnonymous(); } public record GetMenuListBasedMenuSetForTreeParameters( [property: QueryParam] int Type, [property: QueryParam] int ModuleId, [property: FromBody] CriteriaDTO CriteriaDTO, [property: FromHeader] string Login ); protected override async Task> ExecuteAsync(GetMenuListBasedMenuSetForTreeParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var Result = await _menuBLL.GetMenuListBasedMenuSetForTree(req.Type, req.ModuleId, req.CriteriaDTO, LoginDTO!); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse(Result, CacheKeyLevel.NOT_REQUIRED, LoginDTO); } catch (Exception ex) { Logger.LogError(ex, "Error executing GetMenuListBasedMenuSetForTree"); return await GB5Shared.ResponseStandard.Response.CreateExceptionError(ex, CacheKeyLevel.NOT_REQUIRED, LoginDTO, ex.Message, 500); } } } }