This commit is contained in:
laodaming 2023-08-14 15:18:07 +08:00
parent 13c6eea1a8
commit 357f402031

View File

@ -175,13 +175,13 @@ func getCombineImage(ctx context.Context, svcCtx *svc.ServiceContext, parseInfo
return "", errors.New("product template info`template_info is empty") return "", errors.New("product template info`template_info is empty")
} }
//反序列化替换其中一些参数 //反序列化替换其中一些参数
var combineInfo map[string]interface{} var moduleInfo interface{}
if err = json.Unmarshal([]byte(*productTemplate.TemplateInfo), &combineInfo); err != nil { if err = json.Unmarshal([]byte(*productTemplate.TemplateInfo), &moduleInfo); err != nil {
logx.Error("failed to parse json:template_info:", err) logx.Error("failed to parse json:template_info:", err)
return "", err return "", err
} }
//需要替换的参数 //需要替换的参数
replaceData := map[string]interface{}{ paramData := map[string]interface{}{
"logo_url": parseInfo.RenderData.Logo, "logo_url": parseInfo.RenderData.Logo,
"website": parseInfo.RenderData.Website, "website": parseInfo.RenderData.Website,
"slogan": parseInfo.RenderData.Slogan, "slogan": parseInfo.RenderData.Slogan,
@ -214,17 +214,20 @@ func getCombineImage(ctx context.Context, svcCtx *svc.ServiceContext, parseInfo
return "", err return "", err
} }
//赋值 //赋值
replaceData["colors"] = materialMetaData["colors"] paramData["colors"] = materialMetaData["colors"]
replaceData["logo_url"] = materialMetaData["logo_url"] paramData["logo_url"] = materialMetaData["logo_url"]
replaceData["shape"] = materialMetaData["shape"] paramData["shape"] = materialMetaData["shape"]
replaceData["is_crop"] = materialMetaData["is_crop"] paramData["is_crop"] = materialMetaData["is_crop"]
replaceData["ratio"] = materialMetaData["ratio"] paramData["ratio"] = materialMetaData["ratio"]
replaceData["line"] = materialMetaData["line"] paramData["line"] = materialMetaData["line"]
replaceData["other"] = materialMetaData["other"] paramData["other"] = materialMetaData["other"]
replaceData["other1"] = materialMetaData["other1"] paramData["other1"] = materialMetaData["other1"]
} }
} }
combineInfo["param_data"] = replaceData combineInfo := map[string]interface{}{
"module_data": moduleInfo,
"param_data": paramData,
}
postData, _ := json.Marshal(combineInfo) postData, _ := json.Marshal(combineInfo)
//请求合成图片 //请求合成图片
url := svcCtx.Config.PythonApi.CombineImageUrl url := svcCtx.Config.PythonApi.CombineImageUrl