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