Commit bb5a0cbc by mushishixian

修改属性

parent 699d1ab6
......@@ -2,6 +2,7 @@ package service
import (
"encoding/json"
"fmt"
"github.com/iancoleman/orderedmap"
"go_sku_server/pkg/logger"
"go_sku_server/pkg/mongo"
......@@ -23,7 +24,11 @@ func (ls *LyService) GetSpuAttr(spuId string) (attrsResult interface{}) {
if err != nil && err != mgo.ErrNotFound {
logger.Select("sku_query").Error(err.Error())
}
if spuAttr.Attrs != "" {
fmt.Println(spuAttr.AttrsExtend)
//如果有attrs_extend,就去取attrs_extend
if len(spuAttr.AttrsExtend) != 0 {
return spuAttr.AttrsExtend
} else if spuAttr.Attrs != "" {
o := orderedmap.New()
err := json.Unmarshal([]byte(spuAttr.Attrs), &o)
if err != nil {
......
......@@ -85,10 +85,16 @@ func (ls *LyService) GetCacheClass(classId int64) string {
type SpuAttr struct {
SpuId string `bson:"spu_id"`
AttrsExtend string `bson:"attrs_extend"`
AttrsExtend []AttrsExtend `bson:"attrs_extend"`
Attrs string `bson:"attrs"`
}
type AttrsExtend struct {
AttrName string `bson:"attr_name" json:"attr_name"`
AttrValue string `bson:"attr_value" json:"attr_value"`
AttrUnit string `bson:"attr_unit" json:"attr_unit,omitempty"`
}
//H获取供应链标准品牌
func (ls *LyService) GetScmBrand(brandId int64) (res interface{}) {
redisCon := gredis.Conn("default_r")
......
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