Backend: - migrations/005: add pg_trgm extension + search indexes on ingredient_mappings - migrations/006: products table with computed expires_at column - ingredient: add Search method (aliases + ILIKE + trgm) + HTTP handler - product: full package — model, repository (CRUD + BatchCreate + ListForPrompt), handler - gemini: add AvailableProducts field to RecipeRequest, include in prompt - recommendation: add ProductLister interface, load user products for personalised prompts - server/main: wire ingredient and product handlers with new routes Flutter: - models: Product, IngredientMapping with json_serializable - ProductService: getProducts, createProduct, updateProduct, deleteProduct, searchIngredients - ProductsNotifier: create/update/delete with optimistic delete - ProductsScreen: expiring-soon section, normal section, swipe-to-delete, edit bottom sheet - AddProductScreen: name field with 300ms debounce autocomplete, qty/unit/days fields - app_router: /products/add route + Badge on Products nav tab showing expiring count - MainShell converted to ConsumerWidget for badge reactivity Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
40 lines
1.2 KiB
Go
40 lines
1.2 KiB
Go
package product
|
|
|
|
import "time"
|
|
|
|
// Product is a user's food item in their pantry.
|
|
type Product struct {
|
|
ID string `json:"id"`
|
|
UserID string `json:"user_id"`
|
|
MappingID *string `json:"mapping_id"`
|
|
Name string `json:"name"`
|
|
Quantity float64 `json:"quantity"`
|
|
Unit string `json:"unit"`
|
|
Category *string `json:"category"`
|
|
StorageDays int `json:"storage_days"`
|
|
AddedAt time.Time `json:"added_at"`
|
|
ExpiresAt time.Time `json:"expires_at"`
|
|
DaysLeft int `json:"days_left"`
|
|
ExpiringSoon bool `json:"expiring_soon"`
|
|
}
|
|
|
|
// CreateRequest is the body for POST /products.
|
|
type CreateRequest struct {
|
|
MappingID *string `json:"mapping_id"`
|
|
Name string `json:"name"`
|
|
Quantity float64 `json:"quantity"`
|
|
Unit string `json:"unit"`
|
|
Category *string `json:"category"`
|
|
StorageDays int `json:"storage_days"`
|
|
}
|
|
|
|
// UpdateRequest is the body for PUT /products/{id}.
|
|
// All fields are optional (nil = keep existing value).
|
|
type UpdateRequest struct {
|
|
Name *string `json:"name"`
|
|
Quantity *float64 `json:"quantity"`
|
|
Unit *string `json:"unit"`
|
|
Category *string `json:"category"`
|
|
StorageDays *int `json:"storage_days"`
|
|
}
|