diff --git a/model/gmodel/fs_shopping_cart_logic.go b/model/gmodel/fs_shopping_cart_logic.go index 6ebda339..219b5649 100644 --- a/model/gmodel/fs_shopping_cart_logic.go +++ b/model/gmodel/fs_shopping_cart_logic.go @@ -52,16 +52,16 @@ type ProductInfo struct { ProductSn string `json:"product_sn"` } type ModelInfo struct { - ModelJson string `json:"model_json"` //模型设计json数据 + ModelJson interface{} `json:"model_json"` //模型设计json数据 } type FittingInfo struct { - FittingJson string `json:"fitting_json"` //配件设计json数据 - FittingName string `json:"fitting_name"` //配件名称 + FittingJson interface{} `json:"fitting_json"` //配件设计json数据 + FittingName string `json:"fitting_name"` //配件名称 } type TemplateInfo struct { - TemplateJson string `json:"template_json"` //模板设计json数据 - TemplateTag string `json:"template_tag"` //模板标签 + TemplateJson interface{} `json:"template_json"` //模板设计json数据 + TemplateTag string `json:"template_tag"` //模板标签 } type SizeInfo struct { Inch string `json:"inch"` @@ -76,8 +76,8 @@ type UserDiyInformation struct { Slogan string `json:"slogan"` //slogan } type LightInfo struct { - LightJson string `json:"light_json"` //灯光设计json数据 - LightName string `json:"light_name"` //名称 + LightJson interface{} `json:"light_json"` //灯光设计json数据 + LightName string `json:"light_name"` //名称 } // 获取单个 diff --git a/server/shopping-cart/internal/logic/addtocartlogic.go b/server/shopping-cart/internal/logic/addtocartlogic.go index b6f4e21c..6bdaa079 100644 --- a/server/shopping-cart/internal/logic/addtocartlogic.go +++ b/server/shopping-cart/internal/logic/addtocartlogic.go @@ -88,12 +88,12 @@ func (l *AddToCartLogic) AddToCart(req *types.AddToCartReq, userinfo *auth.UserI return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get product info") } var ( - templateJson string //模板表的记录中的json设计信息 - templateTag string //模板表的模板标签 - fittingJson string //配件的json设计信息 - fittingName string //配件名 - lightJson string //灯光设计数据 - lightName string //灯光名字 + templateJson interface{} //模板表的记录中的json设计信息 + templateTag string //模板表的模板标签 + fittingJson interface{} //配件的json设计信息 + fittingName string //配件名 + lightJson interface{} //灯光设计数据 + lightName string //灯光名字 ) //有模板 if req.TemplateId > 0 { @@ -114,7 +114,10 @@ func (l *AddToCartLogic) AddToCart(req *types.AddToCartReq, userinfo *auth.UserI if templateInfo.TemplateInfo == nil || *templateInfo.TemplateInfo == "" { return resp.SetStatusWithMessage(basic.CodeServiceErr, "the template`s design info is empty") } - templateJson = *templateInfo.TemplateInfo + if err = json.Unmarshal([]byte(*templateInfo.TemplateInfo), &templateJson); err != nil { + logx.Error(err) + return resp.SetStatusWithMessage(basic.CodeJsonErr, "failed to parse template design info") + } templateTag = *templateInfo.TemplateTag } //有配件 @@ -133,7 +136,10 @@ func (l *AddToCartLogic) AddToCart(req *types.AddToCartReq, userinfo *auth.UserI if fittingInfo.ModelInfo == nil || *fittingInfo.ModelInfo == "" { return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "the fitting`s design info is empty") } - fittingJson = *fittingInfo.ModelInfo + if err = json.Unmarshal([]byte(*fittingInfo.ModelInfo), &fittingJson); err != nil { + logx.Error(err) + return resp.SetStatusWithMessage(basic.CodeJsonErr, "failed to parse fitting design info") + } fittingName = *fittingInfo.Title } //获取尺寸信息 @@ -180,7 +186,10 @@ func (l *AddToCartLogic) AddToCart(req *types.AddToCartReq, userinfo *auth.UserI } lightName = *lightInfo.Name if lightInfo.Info != nil && *lightInfo.Info != "" { - lightJson = *lightInfo.Info + if err = json.Unmarshal([]byte(*lightInfo.Info), &lightJson); err != nil { + logx.Error(err) + return resp.SetStatusWithMessage(basic.CodeJsonErr, "failed to parse light design info") + } } } var sizeKeyInfo gmodel.SizeInfo