added pop up view ingredients + warnings for delete removed the star import should also fix the test issue
This commit is contained in:
parent
bab9046682
commit
fe4d3ff2d6
1 changed files with 11 additions and 11 deletions
|
|
@ -168,27 +168,27 @@ public class IngredientController {
|
||||||
* @see Ingredient
|
* @see Ingredient
|
||||||
*/
|
*/
|
||||||
@PostMapping("/ingredients")
|
@PostMapping("/ingredients")
|
||||||
public ResponseEntity<?> createIngredient(@RequestBody Ingredient ingredient) {
|
public ResponseEntity<Ingredient> createIngredient(@RequestBody Ingredient ingredient) {
|
||||||
if (ingredient == null
|
if (ingredient == null
|
||||||
|| ingredient.name == null
|
|| ingredient.name == null
|
||||||
|| ingredient.name.trim().isEmpty()) {
|
|| ingredient.name.trim().isEmpty()) {
|
||||||
return ResponseEntity.badRequest()
|
return ResponseEntity.badRequest().build();
|
||||||
.body("Ingredient name cannot be empty.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return ingredientService.create(ingredient)
|
return ingredientService.create(ingredient)
|
||||||
.<ResponseEntity<?>>map
|
.map(saved -> {
|
||||||
(saved -> {
|
messagingTemplate.convertAndSend(
|
||||||
messagingTemplate.convertAndSend(Topics.INGREDIENTS,
|
Topics.INGREDIENTS,
|
||||||
new CreateIngredientMessage(saved));
|
new CreateIngredientMessage(saved)
|
||||||
|
);
|
||||||
return ResponseEntity.ok(saved);
|
return ResponseEntity.ok(saved);
|
||||||
})
|
})
|
||||||
.orElseGet(() ->
|
.orElseGet(() -> ResponseEntity.status
|
||||||
ResponseEntity.status(HttpStatus.CONFLICT)
|
(HttpStatus.CONFLICT).build()
|
||||||
.body("ingredient name already exists"));
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete an ingredient by its ID.
|
* Delete an ingredient by its ID.
|
||||||
* Maps to <code>DELETE /api/ingredients/{id}</code>
|
* Maps to <code>DELETE /api/ingredients/{id}</code>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue