Commit b4759a26 by 杨树贤

加上替换特殊符号逻辑

parent aa171feb
Showing with 16 additions and 4 deletions
......@@ -2,15 +2,17 @@ package service
import (
"encoding/json"
"github.com/iancoleman/orderedmap"
"go_sku_server/pkg/logger"
"go_sku_server/pkg/mongo"
"strconv"
"strings"
"github.com/iancoleman/orderedmap"
"gopkg.in/mgo.v2"
"gopkg.in/mgo.v2/bson"
"strconv"
)
//获取Spu的属性
// 获取Spu的属性
func (ls *LyService) GetSpuAttr(spuId string) (attrsResult interface{}) {
var spuAttr SpuAttr
var attrsList []interface{}
......@@ -26,7 +28,17 @@ func (ls *LyService) GetSpuAttr(spuId string) (attrsResult interface{}) {
//fmt.Println(spuAttr.AttrsExtend)
//如果有attrs_extend,就去取attrs_extend
if len(spuAttr.AttrsExtend) != 0 {
return spuAttr.AttrsExtend
//便利AttrsExtend的值
for _, value := range spuAttr.AttrsExtend {
data := make(map[string]interface{})
data["attr_name"] = value.AttrName
//€符号全部替换为逗号
data["attr_value"] = strings.ReplaceAll(value.AttrValue, "€", ",")
data["attr_unit"] = value.AttrUnit
attrsList = append(attrsList, data)
attrsResult = attrsList
}
return attrsResult
} else if spuAttr.Attrs != "" {
o := orderedmap.New()
err := json.Unmarshal([]byte(spuAttr.Attrs), &o)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment