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