add topping recipe display & fix bugs

This commit is contained in:
pakintada@gmail.com 2024-02-07 15:39:19 +07:00
parent 7d6988f581
commit ece4cef205
8 changed files with 421 additions and 33 deletions

View file

@ -57,6 +57,19 @@ type MaterialSetting struct {
RawMaterialUnit string `json:"RawMaterialUnit"`
}
func (r *MaterialSetting) ToMap() map[string]interface{} {
var m map[string]interface{}
recipeRecord, _ := json.Marshal(r)
json.Unmarshal(recipeRecord, &m)
return m
}
func (r *MaterialSetting) FromMap(m MaterialSetting) MaterialSetting {
recipeRecord, _ := json.Marshal(m)
json.Unmarshal(recipeRecord, &r)
return *r
}
type Recipe01 struct {
Description string `json:"Description"`
ExtendID int `json:"ExtendID"`
@ -140,6 +153,19 @@ type ToppingGroup struct {
OtherName string `json:"otherName"`
}
func (r *ToppingGroup) ToMap() map[string]interface{} {
var m map[string]interface{}
recipeRecord, _ := json.Marshal(r)
json.Unmarshal(recipeRecord, &m)
return m
}
func (r *ToppingGroup) FromMap(m map[string]interface{}) ToppingGroup {
recipeRecord, _ := json.Marshal(m)
json.Unmarshal(recipeRecord, &r)
return *r
}
type ToppingList struct {
ExtendID int `json:"ExtendID"`
OnTOP bool `json:"OnTOP"`
@ -163,3 +189,16 @@ type ToppingList struct {
UseGram bool `json:"useGram"`
Weight_float int `json:"weight_float"`
}
func (r *ToppingList) ToMap() map[string]interface{} {
var m map[string]interface{}
recipeRecord, _ := json.Marshal(r)
json.Unmarshal(recipeRecord, &m)
return m
}
func (r *ToppingList) FromMap(m map[string]interface{}) ToppingList {
recipeRecord, _ := json.Marshal(m)
json.Unmarshal(recipeRecord, &r)
return *r
}