- DishSearchResult now carries calories_per_serving (backend entity + repo LEFT JOIN recipes / MIN / GROUP BY; Flutter model + fromJson) - _FoodTile.fromDish shows kcal/serving subtitle when available - _DishPortionSheet quick-select buttons: Row → Wrap to avoid BoxConstraints infinite-width crash inside DraggableScrollableSheet Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
106 lines
4.2 KiB
Go
106 lines
4.2 KiB
Go
package dish
|
|
|
|
import "time"
|
|
|
|
// Dish is a canonical dish record combining dish metadata with optional recipes.
|
|
type Dish struct {
|
|
ID string `json:"id"`
|
|
CuisineSlug *string `json:"cuisine_slug"`
|
|
CategorySlug *string `json:"category_slug"`
|
|
Name string `json:"name"`
|
|
Description *string `json:"description"`
|
|
ImageURL *string `json:"image_url"`
|
|
Tags []string `json:"tags"`
|
|
AvgRating float64 `json:"avg_rating"`
|
|
ReviewCount int `json:"review_count"`
|
|
Recipes []Recipe `json:"recipes,omitempty"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
}
|
|
|
|
// Recipe is a cooking variant attached to a Dish.
|
|
type Recipe struct {
|
|
ID string `json:"id"`
|
|
DishID string `json:"dish_id"`
|
|
Source string `json:"source"`
|
|
Difficulty *string `json:"difficulty"`
|
|
PrepTimeMin *int `json:"prep_time_min"`
|
|
CookTimeMin *int `json:"cook_time_min"`
|
|
Servings *int `json:"servings"`
|
|
CaloriesPerServing *float64 `json:"calories_per_serving"`
|
|
ProteinPerServing *float64 `json:"protein_per_serving"`
|
|
FatPerServing *float64 `json:"fat_per_serving"`
|
|
CarbsPerServing *float64 `json:"carbs_per_serving"`
|
|
FiberPerServing *float64 `json:"fiber_per_serving"`
|
|
Ingredients []RecipeIngredient `json:"ingredients"`
|
|
Steps []RecipeStep `json:"steps"`
|
|
Notes *string `json:"notes,omitempty"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
}
|
|
|
|
// RecipeIngredient is a single ingredient row from recipe_ingredients.
|
|
type RecipeIngredient struct {
|
|
ID string `json:"id"`
|
|
IngredientID *string `json:"ingredient_id"`
|
|
Name string `json:"name"`
|
|
Amount float64 `json:"amount"`
|
|
UnitCode *string `json:"unit_code"`
|
|
IsOptional bool `json:"is_optional"`
|
|
SortOrder int `json:"sort_order"`
|
|
}
|
|
|
|
// RecipeStep is a single step row from recipe_steps.
|
|
type RecipeStep struct {
|
|
ID string `json:"id"`
|
|
StepNumber int `json:"step_number"`
|
|
Description string `json:"description"`
|
|
TimerSeconds *int `json:"timer_seconds"`
|
|
ImageURL *string `json:"image_url"`
|
|
}
|
|
|
|
// DishSearchResult is a lightweight dish returned by the search endpoint.
|
|
type DishSearchResult struct {
|
|
ID string `json:"id"`
|
|
Name string `json:"name"`
|
|
ImageURL *string `json:"image_url,omitempty"`
|
|
AvgRating float64 `json:"avg_rating"`
|
|
CaloriesPerServing *float64 `json:"calories_per_serving,omitempty"`
|
|
}
|
|
|
|
// CreateRequest is the body used to create a new dish + recipe at once.
|
|
// Used when saving a Gemini-generated recommendation.
|
|
type CreateRequest struct {
|
|
Name string `json:"name"`
|
|
Description string `json:"description"`
|
|
CuisineSlug string `json:"cuisine_slug"`
|
|
ImageURL string `json:"image_url"`
|
|
Tags []string `json:"tags"`
|
|
Source string `json:"source"`
|
|
Difficulty string `json:"difficulty"`
|
|
PrepTimeMin int `json:"prep_time_min"`
|
|
CookTimeMin int `json:"cook_time_min"`
|
|
Servings int `json:"servings"`
|
|
Calories float64 `json:"calories_per_serving"`
|
|
Protein float64 `json:"protein_per_serving"`
|
|
Fat float64 `json:"fat_per_serving"`
|
|
Carbs float64 `json:"carbs_per_serving"`
|
|
Ingredients []IngredientInput `json:"ingredients"`
|
|
Steps []StepInput `json:"steps"`
|
|
}
|
|
|
|
// IngredientInput is a single ingredient in the create request.
|
|
type IngredientInput struct {
|
|
Name string `json:"name"`
|
|
Amount float64 `json:"amount"`
|
|
Unit string `json:"unit"`
|
|
IsOptional bool `json:"is_optional"`
|
|
}
|
|
|
|
// StepInput is a single step in the create request.
|
|
type StepInput struct {
|
|
Number int `json:"number"`
|
|
Description string `json:"description"`
|
|
TimerSeconds *int `json:"timer_seconds"`
|
|
}
|