Skip to content
Snippets Groups Projects
Commit 10566dfa authored by michael.ramusi's avatar michael.ramusi
Browse files

order with args

parent d021512b
Branches
No related tags found
No related merge requests found
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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment