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