chore: Refactor ScenarioController to use @PathVariable for scenario ID
This commit is contained in:
@@ -1,7 +1,9 @@
|
|||||||
package com.olympus.hermione.controllers;
|
package com.olympus.hermione.controllers;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
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.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
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;
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
|
@CrossOrigin
|
||||||
public class ScenarioController {
|
public class ScenarioController {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
@@ -27,25 +30,8 @@ public class ScenarioController {
|
|||||||
return scenarioRepository.findAll();
|
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}")
|
@GetMapping("/scenarios/{id}")
|
||||||
public Scenario getScenario(@RequestParam String id) {
|
public Scenario getScenario(@PathVariable String id) {
|
||||||
return scenarioRepository.findById(id).get();
|
return scenarioRepository.findById(id).get();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -55,4 +41,6 @@ public class ScenarioController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user