Most everything is implemented, included a state handler and a pretty simple (but workable) system for managing state in HTML. Nice and simple for now. There is still much work to be done, but the rest is simple backend creation and error handling. And then input validation...a nightmare.
50 lines
1.5 KiB
Go
50 lines
1.5 KiB
Go
package domain
|
|
|
|
import "time"
|
|
|
|
// RecipeDuration is the duration to prepare recipe. It has JSON tags which allows it to be
|
|
// marshaled into a JSON object and stored in the database (JSONB).
|
|
type RecipeDuration struct {
|
|
Total int `json:"total"`
|
|
Prep int `json:"prep"`
|
|
Cook int `json:"cook"`
|
|
}
|
|
|
|
// RecipeMeal is the database enum E_MEAL which defines the meal type of a recipe. Postgres enums
|
|
// are case sensitive so these must match the values in the database exactly.
|
|
type RecipeMeal string
|
|
|
|
const (
|
|
MealBreakfast RecipeMeal = "breakfast"
|
|
MealLunch RecipeMeal = "lunch"
|
|
MealDinner RecipeMeal = "dinner"
|
|
MealDessert RecipeMeal = "dessert"
|
|
MealSnack RecipeMeal = "snack"
|
|
MealSide RecipeMeal = "side"
|
|
MealOther RecipeMeal = "other"
|
|
)
|
|
|
|
// RecipeIngredient is a single ingredients in a recipe. These have JSON tags which allow them
|
|
// to be marshaled into a JSON array and stored in the database (JSONB).
|
|
type RecipeIngredient struct {
|
|
Name string `json:"name"`
|
|
Quantity string `json:"quantity"`
|
|
}
|
|
|
|
// Recipe is the database model of a recipe. There is no need to map to a different model so
|
|
// this will remain in the domain.
|
|
type Recipe struct {
|
|
Id int
|
|
Title string
|
|
Description string
|
|
Instructions []string
|
|
Serves int
|
|
Difficulty int
|
|
Duration RecipeDuration
|
|
Category RecipeMeal
|
|
Ingredients []RecipeIngredient // Just a list of ingredients
|
|
UserId int
|
|
Modified *time.Time // Pointer to allow null
|
|
Created time.Time
|
|
}
|