Files
mealprep/backend/src/main/java/com/recipeapp/recipe/IngredientController.java
Marcel Raddatz 9ec703abcd Implement Recipe, Planning, Shopping, Pantry, and Admin domains
Outside-in TDD for all 5 remaining domains (128 tests total):
- Recipe: CRUD, ingredients autocomplete/patch, tags, categories (27 tests)
- Planning: week plans, slots, confirm, suggestions, variety score, cooking logs (24 tests)
- Shopping: generate from plan, publish, check/add/remove items (15 tests)
- Pantry: CRUD with expiry sorting (11 tests)
- Admin: user management, password reset, audit logging (13 tests)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-01 21:56:51 +02:00

42 lines
1.4 KiB
Java

package com.recipeapp.recipe;
import com.recipeapp.recipe.dto.*;
import jakarta.validation.Valid;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.security.Principal;
import java.util.List;
import java.util.UUID;
@RestController
@RequestMapping("/v1/ingredients")
public class IngredientController {
private final RecipeService recipeService;
private final HouseholdResolver householdResolver;
public IngredientController(RecipeService recipeService, HouseholdResolver householdResolver) {
this.recipeService = recipeService;
this.householdResolver = householdResolver;
}
@GetMapping
public List<IngredientResponse> searchIngredients(
Principal principal,
@RequestParam(required = false) String search,
@RequestParam(required = false) Boolean isStaple) {
UUID householdId = householdResolver.resolve(principal.getName());
return recipeService.searchIngredients(householdId, search, isStaple);
}
@PatchMapping("/{id}")
public IngredientResponse patchIngredient(
Principal principal,
@PathVariable UUID id,
@Valid @RequestBody IngredientPatchRequest request) {
UUID householdId = householdResolver.resolve(principal.getName());
return recipeService.patchIngredient(householdId, id, request);
}
}