using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using SkillManagementBLL.SkillGroup; using static GB5Shared.GB5Constant.Constant; namespace SkillManagementSL.EndPoints.SkillGroup { public class GetSkillGroup : BaseEndpoint> { private readonly ISkillGroupBLL _bll; public GetSkillGroup(ISkillGroupBLL bll) { _bll = bll; } public override void Configure() { Get("/SkillGroup/GetSkillGroup"); AllowAnonymous(); } public record GetSkillGroupParameters( [property: FromHeader] string Login, [property: QueryParam] int GroupId ); protected override string? GetCacheKey(GetSkillGroupParameters req, LoginDTO login) { try { return $"Skill:Group:{login.ClientId}:{req.GroupId}"; } catch (Exception) { throw; } } protected override async Task> ExecuteAsync( GetSkillGroupParameters req, LoginDTO login, CancellationToken ct) { try { // Only Get By Id var result = await _bll.GetById(req.GroupId, login, ct); return await GB5Shared.ResponseStandard.Response .CreateSuccessResponse( result, CacheKeyLevel.CLIENT_LEVEL, login); } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response .CreateExceptionError( ex, CacheKeyLevel.CLIENT_LEVEL, login, ex.Message, 500); } } } }