- Rename catalog: ingredient/* → product/* (canonical_name, barcode, nutrition per 100g)
- Rename pantry: product/* → userproduct/* (user-owned items with expiry)
- Squash migrations into single 001_initial_schema.sql (clean-db baseline)
- product_categories: add English canonical name column; fix COALESCE in queries
- Remove product_translations: product names are stored in their original language
- Add default_unit_name to product API responses via unit_translations JOIN
- Add cmd/importoff: bulk import from OpenFoodFacts JSONL dump (COPY + ON CONFLICT)
- Diary: support product_id entries alongside dish_id (CHECK num_nonnulls = 1)
- Home: getLoggedCalories joins both recipes and catalog products
- Flutter: rename models/providers/services to match backend rename
- Flutter: add barcode scan flow for diary (mobile_scanner, product_portion_sheet)
- Flutter: localise 6 new keys across 12 languages (barcode scan, portion weight)
- Routes: GET /products/search, GET /products/barcode/{barcode}, /user-products
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
42 lines
1.5 KiB
Go
42 lines
1.5 KiB
Go
package userproduct
|
|
|
|
import "time"
|
|
|
|
// UserProduct is a user's food item in their pantry.
|
|
type UserProduct struct {
|
|
ID string `json:"id"`
|
|
UserID string `json:"user_id"`
|
|
PrimaryProductID *string `json:"primary_product_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 /user-products.
|
|
type CreateRequest struct {
|
|
PrimaryProductID *string `json:"primary_product_id"`
|
|
// Accept "mapping_id" as a legacy alias for backward compatibility.
|
|
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 /user-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"`
|
|
}
|