using FastEndpoints; using FrameworkBLL.Menu; using FrameworkBLL.Module; using FrameworkSL.Endpoints.Module; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using static GB5Shared.GB5Constant.Constant; namespace FrameworkSL.Endpoints.Menu { public class GetMenu : BaseEndpoint> { private readonly IMenuBLL _menuBLL; public GetMenu(IMenuBLL IMenuBLL) { _menuBLL = IMenuBLL; } public override void Configure() { Get("/Menu/GetMenu"); AllowAnonymous(); } public record GetMenuParameters( [property: FromHeader] string Login, [property: QueryParam] int MenuId ); protected override string? GetCacheKey(GetMenuParameters GetMenuParameter, LoginDTO LoginDTO) { try { return KeyGenerator.KeyGeneration(GetMenuParameter.MenuId!, EntityConstant.MENU, CacheKeyLevel.ROLE_LEVEL, LoginDTO); } catch (Exception) { throw; } } protected override async Task> ExecuteAsync(GetMenuParameters GetMenuParameter, LoginDTO LoginDTO, CancellationToken ct) { try { var Result = await _menuBLL.GetMenu(GetMenuParameter.MenuId , LoginDTO!); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse(Result, CacheKeyLevel.NOT_REQUIRED, LoginDTO); } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response.CreateExceptionError(ex, CacheKeyLevel.NOT_REQUIRED, LoginDTO, ex.Message, 500); } } } }