using FastEndpoints; using FrameworkBLL.ParameterMap; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using System.Threading; using static GB5Shared.GB5Constant.Constant; namespace FrameworkSL.Endpoints.ParameterMap { public class GetParameterMap : BaseEndpoint { private readonly IParameterMapBLL _parameterMapBLL; public GetParameterMap(IParameterMapBLL parameterMapBLL) { _parameterMapBLL = parameterMapBLL; } public override void Configure() { Get("/ParameterMap/GetParameterMap"); AllowAnonymous(); } public record GetParameterMapParameters( [property: QueryParam] int ParameterMapId, [property: FromHeader] string Login ); protected override string? GetCacheKey(GetParameterMapParameters GetParameterMapParameters, LoginDTO LoginDTO) { try { return KeyGenerator.KeyGeneration(GetParameterMapParameters.ParameterMapId!, EntityConstant.OBJECTPARAMETER, CacheKeyLevel.USER_LEVEL, LoginDTO); } catch (Exception) { throw; } } protected override async Task> ExecuteAsync(GetParameterMapParameters parameters, LoginDTO loginDTO, CancellationToken ct) { try { var result = await _parameterMapBLL.GetParameterMap(parameters.ParameterMapId, 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); } } } }