From d2766d5bd34cc2d0f944166b74fcee485c62eb89 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Tue, 11 Jul 2023 17:45:34 +0800 Subject: [PATCH] fix --- .../internal/logic/getproductinfologic.go | 26 ++++++++++++------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/server/product/internal/logic/getproductinfologic.go b/server/product/internal/logic/getproductinfologic.go index 6d09cab9..3ef3b921 100644 --- a/server/product/internal/logic/getproductinfologic.go +++ b/server/product/internal/logic/getproductinfologic.go @@ -130,12 +130,14 @@ func (l *GetProductInfoLogic) GetProductInfo(req *types.GetProductInfoReq, useri var title types.SizeTitle if err = json.Unmarshal([]byte(*v.Title), &title); err != nil { logx.Error(err) - return resp.SetStatusWithMessage(basic.CodeJsonErr, "failed to decode size info`s title") + return resp.SetStatusWithMessage(basic.CodeJsonErr, "failed to parse size info`s title") } var modelInfo map[string]interface{} - if err = json.Unmarshal([]byte(*model3dList[model3dIndex].ModelInfo), &modelInfo); err != nil { - logx.Error(err) - return resp.SetStatusWithMessage(basic.CodeJsonErr, "failed to parse model info") + if model3dList[model3dIndex].ModelInfo != nil && *model3dList[model3dIndex].ModelInfo != "" { + if err = json.Unmarshal([]byte(*model3dList[model3dIndex].ModelInfo), &modelInfo); err != nil { + logx.Error(err) + return resp.SetStatusWithMessage(basic.CodeJsonErr, "failed to parse model info") + } } cover := "" if modelInfo["cover"] != nil && modelInfo["cover"].(string) != "" { @@ -224,9 +226,11 @@ func (l *GetProductInfoLogic) GetProductInfo(req *types.GetProductInfoReq, useri model3dInfo := allModel3dList[allModel3dIndex] //解码template info var templateInfoRsp map[string]interface{} - if err = json.Unmarshal([]byte(*tmp.TemplateInfo), &templateInfoRsp); err != nil { - logx.Error(err) - return resp.SetStatusWithMessage(basic.CodeJsonErr, "failed to parse template info") + if tmp.TemplateInfo != nil && *tmp.TemplateInfo != "" { + if err = json.Unmarshal([]byte(*tmp.TemplateInfo), &templateInfoRsp); err != nil { + logx.Error(err) + return resp.SetStatusWithMessage(basic.CodeJsonErr, "failed to parse template info") + } } if templateInfoRsp["cover"] != nil && templateInfoRsp["cover"].(string) != "" { cover := templateInfoRsp["cover"].(string) @@ -240,9 +244,11 @@ func (l *GetProductInfoLogic) GetProductInfo(req *types.GetProductInfoReq, useri } //解码模型数据 var modelInfoRsp map[string]interface{} - if err = json.Unmarshal([]byte(*model3dInfo.ModelInfo), &modelInfoRsp); err != nil { - logx.Error(err) - return resp.SetStatusWithMessage(basic.CodeJsonErr, "failed to parse template info") + if model3dInfo.ModelInfo != nil && *model3dInfo.ModelInfo != "" { + if err = json.Unmarshal([]byte(*model3dInfo.ModelInfo), &modelInfoRsp); err != nil { + logx.Error(err) + return resp.SetStatusWithMessage(basic.CodeJsonErr, "failed to parse model info") + } } modelInfoRsp["id"] = allModel3dList[allModel3dIndex].Id //解码灯光数据