generated from VLADIMIR/template
fix
This commit is contained in:
+14
-1
@@ -255,12 +255,25 @@ func (s *server) GetScenariosCatalog(ctx context.Context, req *proto.GetScenario
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (s *server) GetScenario(ctx context.Context, req *proto.GetScenarioReq) (*proto.GetScenarioRsp, error) {
|
||||
func (s *server) GetFullScenario(ctx context.Context, req *proto.GetScenarioReq) (*proto.GetScenarioRsp, error) {
|
||||
claims := ctx.Value("claims").(*processor_jwt.JWTClaims)
|
||||
if !roles.HasRole(claims, roles.Author) {
|
||||
return nil, status.Errorf(codes.PermissionDenied, "permission denied")
|
||||
}
|
||||
|
||||
scenario, err := s.scenarioService.GetFullScenarioByID(ctx, int(req.Id))
|
||||
if err != nil {
|
||||
return &proto.GetScenarioRsp{
|
||||
Error: err.Error(),
|
||||
}, nil
|
||||
}
|
||||
|
||||
return &proto.GetScenarioRsp{
|
||||
Scenario: mapScenario(scenario),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (s *server) GetScenario(ctx context.Context, req *proto.GetScenarioReq) (*proto.GetScenarioRsp, error) {
|
||||
scenario, err := s.scenarioService.GetScenarioByID(ctx, int(req.Id))
|
||||
if err != nil {
|
||||
return &proto.GetScenarioRsp{
|
||||
|
||||
@@ -56,7 +56,7 @@ func (s *ScenarioService) GetScenariosCatalog(
|
||||
return mapScenariosLight(scenarios, s.domain), nil
|
||||
}
|
||||
|
||||
func (s *ScenarioService) GetScenarioByID(
|
||||
func (s *ScenarioService) GetFullScenarioByID(
|
||||
ctx context.Context,
|
||||
id int,
|
||||
) (*Scenario, error) {
|
||||
@@ -67,6 +67,17 @@ func (s *ScenarioService) GetScenarioByID(
|
||||
return mapScenario(scenario, s.domain)
|
||||
}
|
||||
|
||||
func (s *ScenarioService) GetScenarioByID(
|
||||
ctx context.Context,
|
||||
id int,
|
||||
) (*Scenario, error) {
|
||||
scenario, err := s.scenariosRepo.GetScenarioByID(ctx, id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return mapScenarioLight(scenario, s.domain), nil
|
||||
}
|
||||
|
||||
func (s *ScenarioService) UpdateScenarioByID(
|
||||
ctx context.Context,
|
||||
id int,
|
||||
|
||||
Reference in New Issue
Block a user