80 lines
2.4 KiB
Go
80 lines
2.4 KiB
Go
package models
|
|
|
|
import "time"
|
|
|
|
// User represents a user account
|
|
type User struct {
|
|
ID int `json:"id"`
|
|
Email string `json:"email"`
|
|
PasswordHash string `json:"-"` // never expose in JSON
|
|
CreatedAt time.Time `json:"created_at"`
|
|
}
|
|
|
|
// Session represents a user session
|
|
type Session struct {
|
|
Token string `json:"token"`
|
|
UserID int `json:"user_id"`
|
|
ExpiresAt time.Time `json:"expires_at"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
}
|
|
|
|
// Ingredient represents a food ingredient
|
|
type Ingredient struct {
|
|
ID int `json:"id"`
|
|
UserID int `json:"user_id"`
|
|
Name string `json:"name"`
|
|
Unit string `json:"unit"` // e.g., "grams", "ml", "cups", "pieces", "tbsp"
|
|
Tags []Tag `json:"tags,omitempty"`
|
|
}
|
|
|
|
// Tag represents a tag for categorizing ingredients
|
|
type Tag struct {
|
|
ID int `json:"id"`
|
|
UserID int `json:"user_id"`
|
|
Name string `json:"name"`
|
|
}
|
|
|
|
// IngredientTag represents the many-to-many relationship between ingredients and tags
|
|
type IngredientTag struct {
|
|
IngredientID int `json:"ingredient_id"`
|
|
TagID int `json:"tag_id"`
|
|
}
|
|
|
|
// Meal represents a meal recipe
|
|
type Meal struct {
|
|
ID int `json:"id"`
|
|
UserID int `json:"user_id"`
|
|
Name string `json:"name"`
|
|
Description string `json:"description"`
|
|
MealType string `json:"meal_type"` // "breakfast", "lunch", "snack"
|
|
Instructions string `json:"instructions"`
|
|
PrepTime int `json:"prep_time"` // in minutes
|
|
ImageURL string `json:"image_url"`
|
|
}
|
|
|
|
// MealIngredient represents an ingredient in a meal with its quantity
|
|
type MealIngredient struct {
|
|
MealID int `json:"meal_id"`
|
|
IngredientID int `json:"ingredient_id"`
|
|
Quantity float64 `json:"quantity"`
|
|
// Joined fields
|
|
IngredientName string `json:"ingredient_name,omitempty"`
|
|
Unit string `json:"unit,omitempty"`
|
|
}
|
|
|
|
// WeekPlanEntry represents a meal planned for a specific date
|
|
type WeekPlanEntry struct {
|
|
ID int `json:"id"`
|
|
Date time.Time `json:"date"`
|
|
MealID int `json:"meal_id"`
|
|
MealName string `json:"meal_name,omitempty"`
|
|
MealType string `json:"meal_type,omitempty"` // "breakfast", "lunch", "snack"
|
|
}
|
|
|
|
// GroceryItem represents an aggregated ingredient for shopping
|
|
type GroceryItem struct {
|
|
IngredientName string `json:"ingredient_name"`
|
|
TotalQuantity float64 `json:"total_quantity"`
|
|
Unit string `json:"unit"`
|
|
}
|