using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using TMSBLL.Competency; using static GB5Shared.GB5Constant.Constant; namespace TMSSL.EndPoints.Competency { public class GetCompetency : BaseEndpoint> { private readonly ICompetencyBLL _CompetencyBLL; public GetCompetency(ICompetencyBLL competencyBLL) { _CompetencyBLL = competencyBLL; } public override void Configure() { Get("/Competency/GetCompetency"); AllowAnonymous(); } public record GetCompetencyParameters( [property: QueryParam] int CompetencyId, [property: FromHeader] string Login ); protected override string? GetCacheKey(GetCompetencyParameters req, LoginDTO loginDTO) { return KeyGenerator.KeyGeneration(req.CompetencyId, EntityConstant.OBJECTCOMPETENCY, CacheKeyLevel.CLIENT_LEVEL, loginDTO); } protected override async Task> ExecuteAsync(GetCompetencyParameters req, LoginDTO loginDTO, CancellationToken ct) { try { var result = await _CompetencyBLL.GetCompetency(req.CompetencyId, 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); } } } }