From a92c380707fa153f8a876d9a1de0565b897cabfc Mon Sep 17 00:00:00 2001 From: Ann Date: Thu, 28 Sep 2023 17:06:11 +0300 Subject: [PATCH] Enforcing all IngredientController endpoints return reactive types to enable auto-subscription --- .../src/main/java/tacos/web/api/IngredientController.java | 8 ++++---- .../src/main/java/tacos/web/api/IngredientController.java | 8 ++++---- .../src/main/java/tacos/web/api/IngredientController.java | 8 ++++---- .../src/main/java/tacos/web/api/IngredientController.java | 8 ++++---- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/ch12_13/tacocloud-cassandra/tacocloud-api/src/main/java/tacos/web/api/IngredientController.java b/ch12_13/tacocloud-cassandra/tacocloud-api/src/main/java/tacos/web/api/IngredientController.java index 5dbbe7a..8d67c64 100644 --- a/ch12_13/tacocloud-cassandra/tacocloud-api/src/main/java/tacos/web/api/IngredientController.java +++ b/ch12_13/tacocloud-cassandra/tacocloud-api/src/main/java/tacos/web/api/IngredientController.java @@ -44,11 +44,11 @@ public Mono byId(@PathVariable String id) { } @PutMapping("/{id}") - public void updateIngredient(@PathVariable String id, @RequestBody Ingredient ingredient) { + public Mono updateIngredient(@PathVariable String id, @RequestBody Ingredient ingredient) { if (!ingredient.getId().equals(id)) { throw new IllegalStateException("Given ingredient's ID doesn't match the ID in the path."); } - repo.save(ingredient); + return repo.save(ingredient); } @PostMapping @@ -63,8 +63,8 @@ public Mono> postIngredient(@RequestBody Mono deleteIngredient(@PathVariable String id) { + return repo.deleteById(id); } } diff --git a/ch12_13/tacocloud-mongodb/tacocloud-api/src/main/java/tacos/web/api/IngredientController.java b/ch12_13/tacocloud-mongodb/tacocloud-api/src/main/java/tacos/web/api/IngredientController.java index b15fd1f..6661618 100644 --- a/ch12_13/tacocloud-mongodb/tacocloud-api/src/main/java/tacos/web/api/IngredientController.java +++ b/ch12_13/tacocloud-mongodb/tacocloud-api/src/main/java/tacos/web/api/IngredientController.java @@ -44,11 +44,11 @@ public Mono byId(@PathVariable String id) { } @PutMapping("/{id}") - public void updateIngredient(@PathVariable String id, @RequestBody Ingredient ingredient) { + public Mono updateIngredient(@PathVariable String id, @RequestBody Ingredient ingredient) { if (!ingredient.getId().equals(id)) { throw new IllegalStateException("Given ingredient's ID doesn't match the ID in the path."); } - repo.save(ingredient); + return repo.save(ingredient); } @PostMapping @@ -63,8 +63,8 @@ public Mono> postIngredient(@RequestBody Mono deleteIngredient(@PathVariable String id) { + return repo.deleteById(id); } } diff --git a/ch15_16/tacocloud/tacocloud-api/src/main/java/tacos/web/api/IngredientController.java b/ch15_16/tacocloud/tacocloud-api/src/main/java/tacos/web/api/IngredientController.java index b15fd1f..6661618 100644 --- a/ch15_16/tacocloud/tacocloud-api/src/main/java/tacos/web/api/IngredientController.java +++ b/ch15_16/tacocloud/tacocloud-api/src/main/java/tacos/web/api/IngredientController.java @@ -44,11 +44,11 @@ public Mono byId(@PathVariable String id) { } @PutMapping("/{id}") - public void updateIngredient(@PathVariable String id, @RequestBody Ingredient ingredient) { + public Mono updateIngredient(@PathVariable String id, @RequestBody Ingredient ingredient) { if (!ingredient.getId().equals(id)) { throw new IllegalStateException("Given ingredient's ID doesn't match the ID in the path."); } - repo.save(ingredient); + return repo.save(ingredient); } @PostMapping @@ -63,8 +63,8 @@ public Mono> postIngredient(@RequestBody Mono deleteIngredient(@PathVariable String id) { + return repo.deleteById(id); } } diff --git a/ch17/tacocloud/tacocloud-api/src/main/java/tacos/web/api/IngredientController.java b/ch17/tacocloud/tacocloud-api/src/main/java/tacos/web/api/IngredientController.java index b15fd1f..6661618 100644 --- a/ch17/tacocloud/tacocloud-api/src/main/java/tacos/web/api/IngredientController.java +++ b/ch17/tacocloud/tacocloud-api/src/main/java/tacos/web/api/IngredientController.java @@ -44,11 +44,11 @@ public Mono byId(@PathVariable String id) { } @PutMapping("/{id}") - public void updateIngredient(@PathVariable String id, @RequestBody Ingredient ingredient) { + public Mono updateIngredient(@PathVariable String id, @RequestBody Ingredient ingredient) { if (!ingredient.getId().equals(id)) { throw new IllegalStateException("Given ingredient's ID doesn't match the ID in the path."); } - repo.save(ingredient); + return repo.save(ingredient); } @PostMapping @@ -63,8 +63,8 @@ public Mono> postIngredient(@RequestBody Mono deleteIngredient(@PathVariable String id) { + return repo.deleteById(id); } }