using FastEndpoints; using FrameworkBLL.MenuSet; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using static GB5Shared.GB5Constant.Constant; namespace FrameworkSL.Endpoints.MenuSet { public class GetMenuSet : BaseEndpoint> { private readonly IMenuSetBLL _menuSetBLL; public GetMenuSet(IMenuSetBLL menuSetBLL) { _menuSetBLL = menuSetBLL; } public override void Configure() { Get("/MenuSet/GetMenuSet"); AllowAnonymous(); } public record GetMenuSetParameters( [property: FromHeader] string Login, [property: QueryParam] int MenuSetId ); protected override string? GetCacheKey(GetMenuSetParameters req, LoginDTO loginDTO) { try { return KeyGenerator.KeyGeneration(req.MenuSetId!, EntityConstant.OBJECTMENUSET, CacheKeyLevel.USER_LEVEL, loginDTO); } catch (Exception) { throw; } } protected override async Task> ExecuteAsync(GetMenuSetParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var result = await _menuSetBLL.GetMenuSet(req.MenuSetId, LoginDTO); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse(result, CacheKeyLevel.USER_LEVEL, LoginDTO); } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response.CreateExceptionError(ex, CacheKeyLevel.USER_LEVEL, LoginDTO, ex.Message, 500); } } } }