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