Zhongheng Liu 2025-11-22 01:24:04 +01:00
commit 17f4b8bba4

View file

@ -115,17 +115,16 @@ public class RecipeController {
* Deletes a recipe identified by its <code>id</code>.
* </p>
* @param id The id of the recipe to be deleted.
* @return 200 OK with the recipe that was deleted; or 400 Bad Request if the recipe doesn't exist.
* @return 200 OK with true; or 400 Bad Request if the recipe doesn't exist.
*/
@DeleteMapping("/recipe/{id}")
public ResponseEntity<Recipe> deleteRecipe(@PathVariable Long id) {
public ResponseEntity<Boolean> deleteRecipe(@PathVariable Long id) {
if (!recipeRepository.existsById(id)) {
return ResponseEntity.badRequest().build();
}
Recipe removedRecipe = recipeRepository.findById(id).get();
recipeRepository.delete(removedRecipe);
recipeRepository.deleteById(id);
// TODO: Send WS update to propagate deletion
return ResponseEntity.ok(removedRecipe);
return ResponseEntity.ok(true);
}
}