diff options
| -rw-r--r-- | model/recipe.go | 16 | ||||
| -rw-r--r-- | view/recipe.go | 6 | 
2 files changed, 10 insertions, 12 deletions
| diff --git a/model/recipe.go b/model/recipe.go index 1510379..e5cf0a6 100644 --- a/model/recipe.go +++ b/model/recipe.go @@ -3,23 +3,24 @@ package model  import (  	"database/sql"  	"errors" +	"fmt"  	"time"  )  type Recipe struct { -	Id          int64  `json:"id"` +	Id          string `json:"id"`  	Title       string `json:"title"` -	Portions    int    `json:"portions"` +	Portions    string `json:"portions"`  	Url         string `json:"url"`  	Notes       string `json:"notes"` -	Created     int64  `json:"created"` -	LastChanged int64  `json:"last_changed"` +	Created     string `json:"created"` +	LastChanged string `json:"last_changed"`  }  func (r *Recipe) Create() error {  	now := time.Now().Unix() -	r.Created = now -	r.LastChanged = now +	r.Created = fmt.Sprint(now) +	r.LastChanged = r.Created  	query := `INSERT INTO recipes      (title, portions, url, notes, created, last_changed) @@ -32,10 +33,11 @@ VALUES  		return err  	} -	r.Id, err = result.LastInsertId() +	id, err := result.LastInsertId()  	if err != nil {  		return err  	} +	r.Id = fmt.Sprint(id)  	return nil  } diff --git a/view/recipe.go b/view/recipe.go index b0525a1..1dd6045 100644 --- a/view/recipe.go +++ b/view/recipe.go @@ -2,7 +2,6 @@ package view  import (  	"net/http" -	"strconv"  	"xengineering.eu/ceres/model" @@ -10,11 +9,8 @@ import (  )  func Recipe(w http.ResponseWriter, r *http.Request) { -	id_str := mux.Vars(r)[`id`] -	id, _ := strconv.Atoi(id_str) -  	recipe := model.Recipe{} -	recipe.Id = int64(id) +	recipe.Id = mux.Vars(r)[`id`]  	err := recipe.Read()  	if err != nil { | 
