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