using FastEndpoints; using FrameworkBLL.Role; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using static FrameworkDAL.Constant.Constant; namespace FrameworkSL.Endpoints.Role { public class GetRole : BaseEndpoint> { private readonly IRoleBLL _RoleBLL; public GetRole(IRoleBLL IRoleBLL) { _RoleBLL = IRoleBLL; } public override void Configure() { Get("/Role/GetRole"); AllowAnonymous(); } public record GetRoleParameters( [property: FromHeader] string Login, [property: QueryParam] int RoleId ); //protected override string? GetCacheKey(GetRoleParameters Parameters, LoginDTO LoginDTO) //{ // try // { // return KeyGenerator.KeyGeneration(Parameters.RoleId!, EntityConstant.OBJECTROLE, CacheKeyLevel.USER_LEVEL, LoginDTO); // } // catch (Exception) // { // throw; // } //} protected override async Task> ExecuteAsync(GetRoleParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var Result = await _RoleBLL.GetRole(req.RoleId, LoginDTO!); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse(Result, CacheKeyLevel.UserLevel, LoginDTO); } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response.CreateExceptionError(ex, CacheKeyLevel.UserLevel, LoginDTO, ex.Message, 500); } } } }