fixed todo delete progatation in recipe

added count to IngredientController about what recipes we have or dont and 2 small typo mistakes

also added counting ingredients to IngredientService

the pipeline failure is bc i forgot tests exist
This commit is contained in:
Aysegul 2026-01-08 22:20:54 +01:00
commit 79e7b01363

View file

@ -94,6 +94,14 @@ public class IngredientController {
* *
* @see Ingredient * @see Ingredient
*/ */
@GetMapping("/ingredients/{id}")
public ResponseEntity<Ingredient> getIngredientById(@PathVariable Long id) {
return ingredientService.findById(id)
.map(ResponseEntity::ok)
.orElseGet(() -> ResponseEntity.notFound().build());
}
@GetMapping("/ingredients/{id}/usage") @GetMapping("/ingredients/{id}/usage")
public ResponseEntity<IngredientUsageResponse> getIngredientUsage(@PathVariable Long id) { public ResponseEntity<IngredientUsageResponse> getIngredientUsage(@PathVariable Long id) {
if (ingredientService.findById(id).isEmpty()) { if (ingredientService.findById(id).isEmpty()) {
@ -107,9 +115,6 @@ public class IngredientController {
/** /**
* Update an existing ingredient by its ID. * Update an existing ingredient by its ID.
* Maps to <code>PATCH /api/ingredients/{id}</code> * Maps to <code>PATCH /api/ingredients/{id}</code>