add edit json v1 WIP, testing

This commit is contained in:
pakintada@gmail.com 2023-10-20 14:32:16 +07:00
parent e5eee656d5
commit ea92145350
11 changed files with 216 additions and 67 deletions

View file

@ -1,5 +1,7 @@
package models
import "encoding/json"
type Recipe struct {
Timestamp string `json:"Timestamp"`
MachineSetting MachineSetting `json:"MachineSetting"`
@ -82,6 +84,19 @@ type Recipe01 struct {
Weight_float int `json:"weight_float"`
}
func (r *Recipe01) ToMap() map[string]interface{} {
var m map[string]interface{}
recipeRecord, _ := json.Marshal(r)
json.Unmarshal(recipeRecord, &m)
return m
}
func (r *Recipe01) FromMap(m map[string]interface{}) Recipe01 {
recipeRecord, _ := json.Marshal(m)
json.Unmarshal(recipeRecord, &r)
return *r
}
type MatRecipe struct {
MixOrder int `json:"MixOrder"`
FeedParameter int `json:"FeedParameter"`