using FastEndpoints; using FrameworkBLL.Taxonomy; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using static GB5Shared.GB5Constant.Constant; namespace FrameworkSL.Endpoints.Taxonomy.Topic { public class GetTopic : BaseEndpoint> { private readonly ITopicBLL _TopicBLL; public GetTopic(ITopicBLL topicBLL) { _TopicBLL = topicBLL; } public override void Configure() { Get("/TaxonomyTopic/GetTopic"); AllowAnonymous(); } public record GetTopicParameters( [property: QueryParam] int TopicId, [property: FromHeader] string Login ); protected override string? GetCacheKey(GetTopicParameters req, LoginDTO loginDTO) => KeyGenerator.KeyGeneration(req.TopicId, EntityConstant.OBJECTTOPIC, CacheKeyLevel.CLIENT_LEVEL, loginDTO); protected override async Task> ExecuteAsync(GetTopicParameters req, LoginDTO loginDTO, CancellationToken ct) { try { var result = await _TopicBLL.GetTopic(req.TopicId, loginDTO!); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse(result, CacheKeyLevel.CLIENT_LEVEL, loginDTO); } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response.CreateExceptionError(ex, CacheKeyLevel.CLIENT_LEVEL, loginDTO, ex.Message, 500); } } } }