mirror of
https://github.com/s-frick/effigenix.git
synced 2026-03-28 11:59:35 +01:00
Backend: - articleId als Pflichtfeld im Recipe-Aggregate (Domain, Application, Infrastructure) - Liquibase-Migration 015 mit defaultValue für bestehende Daten - Alle Tests angepasst (Unit, Integration) Frontend: - UoM-Carousel-Selektor in RecipeCreateScreen, AddBatchScreen, AddIngredientScreen - ArticlePicker-Komponente mit Typeahead-Suche für Artikelauswahl - Auto-Position bei Zutatenzugabe (kein manuelles Feld mehr) - Automatische subRecipeId-Erkennung bei Artikelauswahl - Zutaten-Reorder per Drag im RecipeDetailScreen (Remove + Re-Add) - Artikelnamen statt UUIDs in der Rezept-Detailansicht - Navigation-Context: replace()-Methode ergänzt
53 lines
1.4 KiB
Markdown
53 lines
1.4 KiB
Markdown
# Backend: Atomarer Reorder-Endpoint für Rezept-Zutaten
|
|
|
|
## Kontext
|
|
|
|
Aktuell wird die Umsortierung von Rezept-Zutaten im Frontend durch sequentielles Entfernen und Neu-Hinzufügen aller Zutaten realisiert (Remove + Re-Add). Das ist fehleranfällig und nicht atomar.
|
|
|
|
## Anforderung
|
|
|
|
Neuer Endpoint:
|
|
|
|
```
|
|
PUT /api/recipes/{id}/ingredients/reorder
|
|
```
|
|
|
|
### Request Body
|
|
|
|
```json
|
|
{
|
|
"ingredientOrder": [
|
|
{ "ingredientId": "uuid-1", "position": 1 },
|
|
{ "ingredientId": "uuid-2", "position": 2 },
|
|
{ "ingredientId": "uuid-3", "position": 3 }
|
|
]
|
|
}
|
|
```
|
|
|
|
### Verhalten
|
|
|
|
- Alle `ingredientId`s muessen zum Rezept gehoeren
|
|
- Positionen muessen lueckenlos ab 1 aufsteigend sein
|
|
- Nur bei DRAFT-Status erlaubt
|
|
- Atomare Operation (eine Transaktion)
|
|
- Gibt das aktualisierte `RecipeResponse` zurueck
|
|
|
|
### Fehler
|
|
|
|
- `404` wenn Rezept nicht existiert
|
|
- `400` wenn IDs nicht zum Rezept gehoeren oder Positionen ungueltig
|
|
- `409` wenn Rezept nicht im DRAFT-Status
|
|
|
|
## Betroffene Schichten
|
|
|
|
- **Domain**: `Recipe.reorderIngredients(List<ReorderEntry>)` -> `Result<RecipeError, Void>`
|
|
- **Application**: `ReorderIngredients` Use Case + `ReorderIngredientsCommand`
|
|
- **Infrastructure**: Controller-Endpoint + Request-DTO
|
|
|
|
## Frontend-Anpassung
|
|
|
|
Nach Backend-Implementierung kann `RecipeDetailScreen.tsx` den Remove+Re-Add-Workaround durch einen einzelnen API-Call ersetzen:
|
|
|
|
```ts
|
|
await client.recipes.reorderIngredients(recipeId, { ingredientOrder: [...] });
|
|
```
|