using CMSBLL.Tag; using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using System.Threading; using static GB5Shared.GB5Constant.Constant; namespace CMSSL.Endpoints.Tag { public class GetTag : BaseEndpoint { private readonly ITagBLL _TagBLL; public GetTag(ITagBLL TagBLL) { _TagBLL = TagBLL; } public override void Configure() { Get("/Tag/GetTag"); AllowAnonymous(); } public record GetTagParameters( [property: QueryParam] int TagId, [property: FromHeader] string Login ); //protected override string? GetCacheKey(GetTagParameters GetTagParameters, LoginDTO LoginDTO) //{ // try // { // return KeyGenerator.KeyGeneration(GetTagParameters.TagId!, EntityConstant.Tag, CacheKeyLevel.USER_LEVEL, LoginDTO); // } // catch (Exception) // { // throw; // } //} protected override async Task> ExecuteAsync(GetTagParameters parameters, LoginDTO loginDTO, CancellationToken ct) { try { var result = await _TagBLL.GetTag(parameters.TagId, 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); } } } }