chore: Refactor ScenarioController to use @PathVariable for scenario ID
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
package com.olympus.hermione.controllers;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.CrossOrigin;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@@ -15,6 +17,7 @@ import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
@RestController
|
||||
@CrossOrigin
|
||||
public class ScenarioController {
|
||||
|
||||
@Autowired
|
||||
@@ -27,25 +30,8 @@ public class ScenarioController {
|
||||
return scenarioRepository.findAll();
|
||||
}
|
||||
|
||||
|
||||
// Get single scenario
|
||||
|
||||
|
||||
|
||||
//Exec scenario che prende in input un json con l'id dello scenario e gli input dell'utente e restituisce il risultato dell'esecuzione
|
||||
// {scenarioid: 1, input: {input1: "valore1", input2: "valore2"}} =)> devi definire un DTO per questo json
|
||||
//nuovo metodo executeScenarioNew dello ScenarioExecutionService che prende in input l oggetto definito sopra
|
||||
|
||||
|
||||
|
||||
|
||||
@PostMapping("scenarios")
|
||||
public Scenario createScenario(@RequestBody Scenario scenario) {
|
||||
return scenarioRepository.save(scenario);
|
||||
}
|
||||
|
||||
@GetMapping("/scenarios/{id}")
|
||||
public Scenario getScenario(@RequestParam String id) {
|
||||
public Scenario getScenario(@PathVariable String id) {
|
||||
return scenarioRepository.findById(id).get();
|
||||
}
|
||||
|
||||
@@ -54,5 +40,7 @@ public class ScenarioController {
|
||||
return scenarioExecutionService.executeScenario(scenarioExecutionInput);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user