diff --git a/services/src/main/java/ch/hepia/order/http.java b/services/src/main/java/ch/hepia/order/http.java index fd337fc1cb113af8a2eb284fa03e298a03e85d09..ada7dd4329ffce722c99e5bbfe79154ed62f7a2a 100644 --- a/services/src/main/java/ch/hepia/order/http.java +++ b/services/src/main/java/ch/hepia/order/http.java @@ -1,4 +1,5 @@ package ch.hepia.order; + import ch.hepia.account.*; import ch.hepia.event.*; import ch.hepia.stock.*; @@ -20,18 +21,23 @@ public class http { private static StockService stockService; public static void main(String[] args) { - http.orderService = new OrderService("localhost"); + http.orderService = new OrderService("localhost"); http.accountService = new AccountService("localhost"); http.stockService = new StockService("localhost"); SpringApplication.run(http.class, args); } @RequestMapping("/order") - public Order order(@RequestParam(value="name", defaultValue="World") String name) { - Order o = new Order(5, 1); - o.addProduct(1, 4); - o.addProduct(2, 10); - Event oc = new EventOrderCreated(o.id(), "hello", 1, o.getProducts()); + public Order order( + @RequestParam(value = "idAccount", defaultValue = "1") int idAccount, + @RequestParam(value = "idProduct", defaultValue = "1") int idProduct, + @RequestParam(value = "quantity", defaultValue = "1") int quantity ) { + + int idOrder = 5; + Order o = new Order(idOrder, idAccount); + o.addProduct(idProduct, quantity); + + Event oc = new EventOrderCreated(o.id(), "hello", idAccount, o.getProducts()); http.orderService.send(oc); return o; } @@ -48,7 +54,6 @@ public class http { return o; } - @RequestMapping("/createAccount") public String createAccount(@RequestParam(value = "name", defaultValue = "Orphée") String name) { accountService.send(new EventCreateAccount(1, "Creating the account", name)); @@ -63,4 +68,5 @@ public class http { return null; } + } \ No newline at end of file