using FastEndpoints; using FrameworkBLL.CriteriaConfig; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using static GB5Shared.GB5Constant.Constant; namespace FrameworkSL.Endpoints.CriteriaConfig { public class GetCriteriaConfig : BaseEndpoint> { private readonly ICriteriaConfigBLL _CriteriaConfigBLL; public GetCriteriaConfig(ICriteriaConfigBLL ICriteriaConfigBLL) { _CriteriaConfigBLL = ICriteriaConfigBLL; } public override void Configure() { Get("/CriteriaConfig/GetCriteriaConfig"); AllowAnonymous(); } public record GetCriteriaConfigParameters( [property: FromHeader] string Login, [property: QueryParam] int CriteriaConfigId ); protected override string? GetCacheKey(GetCriteriaConfigParameters Parameters, LoginDTO LoginDTO) { try { return KeyGenerator.KeyGeneration(Parameters.CriteriaConfigId!, EntityConstant.OBJECTCRITERIACONFIG, CacheKeyLevel.USER_LEVEL, LoginDTO); } catch (Exception) { throw; } } protected override async Task> ExecuteAsync(GetCriteriaConfigParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var Result = await _CriteriaConfigBLL.GetCriteriaConfig(req.CriteriaConfigId, 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); } } } }