update recipe model
This commit is contained in:
parent
8228a4f46c
commit
b681a5a9af
7 changed files with 301 additions and 114 deletions
|
|
@ -4,9 +4,10 @@ import (
|
|||
"encoding/json"
|
||||
"log"
|
||||
"os"
|
||||
"recipe-manager/models"
|
||||
)
|
||||
|
||||
func readFile() map[string]interface{} {
|
||||
func readFile() *models.Recipe {
|
||||
file, err := os.Open("data/data.json")
|
||||
|
||||
if err != nil {
|
||||
|
|
@ -16,7 +17,7 @@ func readFile() map[string]interface{} {
|
|||
|
||||
defer file.Close()
|
||||
|
||||
var data map[string]interface{}
|
||||
var data *models.Recipe
|
||||
|
||||
err = json.NewDecoder(file).Decode(&data)
|
||||
|
||||
|
|
@ -29,7 +30,7 @@ func readFile() map[string]interface{} {
|
|||
}
|
||||
|
||||
type Data struct {
|
||||
recipe map[string]interface{}
|
||||
recipe *models.Recipe
|
||||
}
|
||||
|
||||
func NewData() *Data {
|
||||
|
|
@ -38,10 +39,10 @@ func NewData() *Data {
|
|||
}
|
||||
}
|
||||
|
||||
func (d *Data) GetRecipe() map[string]interface{} {
|
||||
func (d *Data) GetRecipe() *models.Recipe {
|
||||
return d.recipe
|
||||
}
|
||||
|
||||
func (d *Data) GetRecipe01() []interface{} {
|
||||
return d.recipe["Recipe01"].([]interface{})
|
||||
func (d *Data) GetRecipe01() []models.Recipe01 {
|
||||
return d.recipe.Recipe01
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue