add string param support

This commit is contained in:
pakintada@gmail.com 2024-01-11 08:12:19 +07:00
parent 98341d2d80
commit 636a700a79
8 changed files with 294 additions and 35 deletions

View file

@ -55,6 +55,7 @@ type RecipeDetailResponse struct {
}
type RecipeDetailMat struct {
StringParam string `json:"StringParam"`
IsUse bool `json:"isUse"`
MaterialID uint64 `json:"materialID"`
Name string `json:"name"`

View file

@ -6,6 +6,7 @@ import (
"recipe-manager/helpers"
"recipe-manager/models"
"recipe-manager/services/logger"
"strconv"
"strings"
"time"
@ -49,6 +50,34 @@ func NewData(taoLogger *logger.TaoLogger) *Data {
defaultFile := "coffeethai02_600.json"
defaultCountry := "tha"
// read latest version
// set latest to default version
latest_version, err := strconv.Atoi(strings.Split(strings.Split(defaultFile, "_")[1], ".")[0])
if err != nil {
taoLogger.Log.Debug("Error when retrieved current version", zap.Error(err))
}
for _, v := range allRecipeFiles[defaultCountry] {
// extract filename as version
current_version_iter, err := strconv.Atoi(strings.Split(strings.Split(v.Name, "_")[1], ".")[0])
if err != nil {
continue
}
if current_version_iter > latest_version {
// taoLogger.Log.Debug("current_version_iter", zap.Any("current_version_iter", current_version_iter))
// set latest
latest_version = current_version_iter
defaultFile = v.Name
}
}
taoLogger.Log.Debug("defaultFile", zap.Any("defaultFile", defaultFile), zap.Any("latest_version", latest_version))
defaultRecipe, err := helpers.ReadRecipeFile(defaultCountry, defaultFile)
if err != nil {
@ -172,6 +201,8 @@ func (d *Data) GetRecipe01ByProductCode(filename, countryID, productCode string)
}
}
d.taoLogger.Log.Debug("GetRecipe01ByProductCode", zap.Any("productCode", productCode), zap.Any("version", recipe.MachineSetting.ConfigNumber))
d.currentRecipe = recipe
// save to map

View file

@ -63,7 +63,6 @@ type Recipe01 struct {
OnTOP bool `json:"OnTOP"`
LastChange string `json:"LastChange"`
MenuStatus int `json:"MenuStatus"`
RemainingCups json.Number `json:"RemainingCups"`
StringParam string `json:"StringParam"`
TextForWarningBeforePay []string `json:"TextForWarningBeforePay"`
CashPrice int `json:"cashPrice"`
@ -104,18 +103,19 @@ func (r *Recipe01) FromMap(m map[string]interface{}) Recipe01 {
}
type MatRecipe struct {
MixOrder int `json:"MixOrder"`
FeedParameter int `json:"FeedParameter"`
FeedPattern int `json:"FeedPattern"`
IsUse bool `json:"isUse"`
MaterialPathId int `json:"materialPathId"`
PowderGram int `json:"powderGram"`
PowderTime int `json:"powderTime"`
StirTime int `json:"stirTime"`
SyrupGram int `json:"syrupGram"`
SyrupTime int `json:"syrupTime"`
WaterCold int `json:"waterCold"`
WaterYield int `json:"waterYield"`
StringParam string `json:"StringParam"`
MixOrder int `json:"MixOrder"`
FeedParameter int `json:"FeedParameter"`
FeedPattern int `json:"FeedPattern"`
IsUse bool `json:"isUse"`
MaterialPathId int `json:"materialPathId"`
PowderGram int `json:"powderGram"`
PowderTime int `json:"powderTime"`
StirTime int `json:"stirTime"`
SyrupGram int `json:"syrupGram"`
SyrupTime int `json:"syrupTime"`
WaterCold int `json:"waterCold"`
WaterYield int `json:"waterYield"`
}
type ToppingSet struct {
@ -152,7 +152,7 @@ type ToppingList struct {
ID int `json:"id"`
IsUse bool `json:"isUse"`
IsShow bool `json:"isShow"`
StringParam string `json:"stringParam"`
StringParam string `json:"StringParam"`
Name string `json:"name"`
NonCashPrice int `json:"nonCashPrice"`
OtherName string `json:"otherName"`

View file

@ -117,12 +117,13 @@ func (rs *recipeService) GetRecipeDetailMat(request *contracts.RecipeDetailReque
break
} else if mat.MaterialName != "" {
mat_name = mat.MaterialName
fmt.Println("SetMat", mat_name)
// fmt.Println("SetMat", mat_name)
break
}
}
result.Result = append(result.Result, contracts.RecipeDetailMat{
StringParam: v.StringParam,
IsUse: v.IsUse,
MaterialID: mat.ID,
Name: mat_name,
@ -147,6 +148,7 @@ func (rs *recipeService) GetRecipeDetailMat(request *contracts.RecipeDetailReque
if len(result.Result) < 30 {
for i := len(result.Result); i < 30; i++ {
result.Result = append(result.Result, contracts.RecipeDetailMat{
StringParam: "",
IsUse: false,
MaterialID: 0,
Name: "",