Commit c93a9e6d by 孙龙

Merge branch 'dev' of http://119.23.72.7/mushishixian/search_server into dev

# Conflicts:
#	go.mod
parents cfd95623 8c76d498
......@@ -12,15 +12,14 @@ import (
func main() {
var path string
flag.StringVar(&path, "config", "conf/config.ini", "配置文件")
flag.StringVar(&path, "config", "conf", "配置文件")
flag.Parse()
if err := boot.Boot(path); err != nil {
panic(err)
}
gin.SetMode(config.Get("web.mode").String())
gin.SetMode(config.Get("web.mode").String())
r := routes.InitRouter()
port := config.Get("web.port").String()
//web改成micro 就是grpc,并直接注册到etcd里面
service := web.NewService(
......
......@@ -8,11 +8,20 @@ import (
func main() {
//MouserService := service.NewMouserServiceImpl()
//MouserGetData(MouserService)
dd := service.OutLink("LM358")
dd := service.OutLink("LM358","-1")
print("niin")
print(dd)
os.Exit(1)
}
//xml := strings.NewReader(resp)
//json, err := xj.Convert(xml)
//if err != nil {
// panic("That's embarrassing...")
//}
//
//json_str := json.String();
////ss := gjson.Get(json_str,"hello").String()
//
//fmt.Println(json_str)
\ No newline at end of file
......@@ -37,4 +37,10 @@ idle_timeout = 20
[mongo]
host = 127.0.0.1:27017
database = liexin_config
\ No newline at end of file
database = liexin_config
[brand]
#是否开启排除品牌
is_not_ti = 1
ti_ly_brand_ids = 23,45069,7754,17484,43215,13421,5220,7636,44534,43556,44543,9429,758,9470,10430,10653,10707,11227,11276,11819,12608,12965,12997,13327,13675,13680,13752
ti_zy_brand_id = 23
\ No newline at end of file
;存放本系统所有的队列名称
[rabmq_all]
;联营数据推送入队列-》go后台任务消费(斌哥脚本)
search_sku_list=search_sku_list
;存放本系统所有的redis键值对和解析
[redis_all]
;供应商redis的首key
SUPPLIER_REDIS_PRE=SUPPLIER_REDIS_INFO_
;需要展示的供应商列表
SUPPLIER_REDIS_LIST_PRE=SUPPLIER_REDIS_LIST_INFO_
;新增sku时判读sku是否存在
SKU_UNIQUE_JUDGE=sku_unique_judge
;品牌信息判断,根据md5后的品牌名称获取id
BRAND_NAME_ALL=brand_name_all
;品牌id,获取品牌名称
BRAND=brand
;供应商品牌信息判断,存在多对一的情况,根据md5后的品牌名称获取标准品牌id
SUPPLIER_BRAND_ALL=supplier_brand_all
;统计调用外联接口的次数的key的前缀 后面接mouser、verical、arrow、master
SEARCH_API_TOTAL_PRE=search_api_total_
;统计调用外联接口失败的次数的key的前缀 后面接mouser、verical、arrow、master
SEARCH_API_ERORR_PRE=search_api_overtime_
;曝光时间记录哈希集合
SEARCH_SHOW_SKU_TIME=search_show_sku_time
;获取关税信息,根据goods_name,brand_name获取
TAX_CUSTOMS_INFO=tax_customs_info
\ No newline at end of file
......@@ -4,4 +4,9 @@
3 ="tme"
[common]
'MOUSER_API'='http://footstone.liexin.net/webapi/handle_mouser'
\ No newline at end of file
'MOUSER_API'='http://footstone.liexin.net/webapi/handle_mouser'
[brand]
is_not_ti = 0
ti_ly_brand_ids=23,45069,7754,17484,43215,13421,5220,7636,44534,43556,44543,9429,758,9470,10430,10653,10707,11227,11276,11819,12608,12965,12997,13327,13675,13680,13752
ti_zy_brand_ids=23
\ No newline at end of file
......@@ -19,7 +19,7 @@ func init() {
func MouserGetData(c *service.MouserServiceImpl) gin_.Endpoint {
return func(context *gin.Context, request interface{}) (response interface{}, err error) {
rsp := &mouser.MouserResponse{}
err = c.MouserGetData(context, request.(*mouser.MouserRequest), rsp)
//err = c.MouserGetData(context, request.(*mouser.MouserRequest), rsp)
return rsp, err
}
}
......
package controller
import (
"fmt"
"github.com/gin-gonic/gin"
"search_server/pkg/common"
"search_server/requests"
"search_server/service"
)
//搜索快手搜搜
//check_button=2&pf=1&keyword=123213&supplier_id=7&offset=2&follow_hit=1&p=1&_=1593582814402
func QuoteIndex(c *gin.Context) {
var request requests.QuoteIndexRequest
if err := c.ShouldBind(&request); err != nil {
fmt.Println(err)
}
if request.Keyword == "" || request.SupplierId == "" {
c.JSON(200, common.GetResponse(1, "缺少参数", []string{}))
return
}
supplierName := "temp"
if supplierName == "" {
c.JSON(200, common.GetResponse(1, "供应商id有误", []string{}))
return
}
service.GetGoodsInfoBySupplier(request)
}
......@@ -34,9 +34,11 @@ require (
github.com/syyongx/php2go v0.9.4
github.com/tidwall/gjson v1.6.0
github.com/urfave/cli v1.22.4 // indirect
github.com/uniplaces/carbon v0.1.6
go.uber.org/zap v1.14.1 // indirect
golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2 // indirect
golang.org/x/sys v0.0.0-20200523222454-059865788121 // indirect
golang.org/x/tools v0.0.0-20191216173652-a0e659d51361
google.golang.org/genproto v0.0.0-20200527145253-8367513e4ece // indirect
google.golang.org/grpc v1.29.1 // indirect
google.golang.org/protobuf v1.24.0
......
package model
import (
"search_server/pkg/config"
)
//获取需要排除的品牌id
//branType = 1 : 联营 2 : 自营
func GetExcludeBrandIds(brandType int) (excludeBrandIds []int) {
isNoTi := config.Get("brand.is_not_ti").String()
//如果关闭,直接返回空数据
if isNoTi == "1" {
return
}
//返回联营的brand_id切片
if brandType == 1 {
tiLyBrandIds := config.Get("brand.ti_ly_brand_ids").Ints(",")
excludeBrandIds = tiLyBrandIds
//获取的是字符串
return
}
//返回自营的ti的brand_id切片
tiZyBrandId := config.Get("brand.ti_zy_brand_ids").Ints(",")
excludeBrandIds = tiZyBrandId
return
}
package model
//联营请求外链后格式化数据
type LyClearData struct {
GoodsID string
GoodsName string
type LyClearGoodsList struct {
GoodsName string `json:"goods_name"` //型号名称
BrandName string `json:"brand_name"` //品牌名称
Desc string `json:"desc"` //描述
GoodsSn string `json:"goods_sn"` //api唯一编码
Docurl string `json:"docurl"` //sku对应供应商的文档路径
Url string `json:"url"` //sku对应供应商的商品详情
GoodsImg string `json:"goods_img"` //sku图片
Cat string `json:"cat"` //分类
RestrictionMessage string `json:"RestrictionMessage"` //额外购买限制内容,如 ‘当前商品不在本地区销售’
Increment uint64 `json:"increment"` //最小包装量、倍数
SinglePrice float64 `json:"single_price"` //最小单价
Tiered []*TierItem //价格梯度数量
}
type TierItem struct {
Purchases uint64 //购买数量
PriceUs float64 //数量对应的英文价格
PriceCn float64 //数量对应的中文价格
}
//联营请求外链后格式化数据
type LyClearDataItem struct {
GoodsName string
GoodsNameTemp string
BrandName string
Desc string
GoodsSn string
Docurl string
Url string
GoodsImg string
Cat string
RestrictionMessage string
increment int
SinglePrice float64
PriceTemp []PriceTempItem
/*
供应商详情
Array
(
[supplier_id] => 4
[supplier_nickname] => tme
[ad_text] => 电子元器件、电工产品和工业自动化元件的全球分销商
[cn_delivery] => 5-9工作日
[hk_delivery] => 4-7工作日
[ad_url] => https://www.ichunt.com/
[sort] => 0
[supplier_logo] => http://img.ichunt.com/images/cms/201912/11/b2c4e3aae9a2312dfe6b9c318b430354.jpg
[status] => 1
[describe] => 电子元器件、电工产品和工业自动化元件的全球分销商
[price_json] => Array
(
[0] => Array
(
[hk] => 1.197
[cn] => 9.2534796
[rate] => 6.9
)
)
)
*/
type SUPPLIER_REDIS_INFO_ struct {
SupplierId string `json:"supplier_id"` //供应商id
SupplierNickname string `json:"supplier_nickname"` //供应商名称
AdText string `json:"ad_text"` //供应商描述
CnDelivery string `json:"cn_delivery"` //国内交货时间
HkDelivery string `json:"hk_delivery"` //香港交货时间
AdUrl string `json:"ad_url"` //供应商官网
Sort string `json:"sort"` //排序
SupplierLogo string `json:"supplier_logo"` //供应商logo
Status string `json:"status"` //状态,1开启
Describe string `json:"describe"` //描述
PriceJson []*PriceJsonItem //价格
}
type PriceJsonItem struct {
hk float64 //购买数量
cn float64 //数量对应的英文价格
rate float64 //数量对应的中文价格
}
/*
联营sku详情
Array
(
[spu_id] => 2.1540893752409E+18
[encoded] =>
[moq] => 624
[mpq] => 1
[old_goods_id] => 0
[goods_type] => 1
[goods_status] => 1
[batch_sn] =>
[stock] => 0
[hk_delivery_time] =>
[cn_delivery_time] =>
[update_time] => 1540967156
[goods_images] =>
[canal] =>
[supplier_id] => 10
[is_expire] => 1
[ladder_price] => Array
(
[0] => Array
(
[purchases] => 624
[price_cn] => 0
[price_us] => 13.42
)
type PriceTempItem struct {
Purchases int
PriceUs float64
PriceCn float64
PriceAc float64
[1] => Array
(
[purchases] => 6240
[price_cn] => 0
[price_us] => 12.12
)
[2] => Array
(
[purchases] => 624000
[price_cn] => 0
[price_us] => 2.383
)
)
)
*/
type LySkuInfo struct {
SpuId string `json:"spu_id"` //spu_id
Encoded string `json:"encoded"`
Moq int `json:"moq"`
Mpq int `json:"mpq"`
OldGoodsId int `json:"old_goods_id"`
GoodsType int `json:"goods_type"`
GoodsStatus int `json:"goods_status"`
BatchSn string `json:"batch_sn"`
Stock string `json:"stock"`
UpdateTime string `json:"update_time"`
GoodsImages string `json:"goods_images"`
Canal string `json:"canal"`
SupplierId string `json:"supplier_id"`
IsExpire string `json:"is_expire"`
HkDeliveryTime string `json:"hk_delivery_time"`
CnDeliveryTime string `json:"cn_delivery_time"`
LadderPrice []*LadderPrice2 `json:"ladder_price"`
}
type LadderPrice2 struct {
Purchases int `json:"purchases"` //数量
PriceUs float64 `json:"price_us"` //英文价格
PriceCn float64 `json:"price_cn"` //中文价格
PriceAc float64 `json:"price_ac"`
}
/*
spu详情
Array
(
[class_id1] => 0
[class_id2] => 0
[class_id3] => 0
[brand_id] => 7087
[spu_name] => SI4704-D50-GM
[status] => 1
[images_l] =>
[encap] =>
[pdf] =>
[spu_brief] =>
[update_time] => 1540893752
)
*/
type LySpuInfo struct {
ClassId1 string `json:"class_id1"` //一级分类
ClassId2 string `json:"class_id2"` //二级分类
ClassId3 string `json:"class_id3"` //三级分类
BrandId string `json:"brand_id"` //品牌ID
SpuName string `json:"spu_name"` //型号名称
Status string `json:"status"` // 状态
ImagesL string `json:"images_l"` //图片
Encap string `json:"encap"` //封装
Pdf string `json:"pdf"` //pdf
SpuBrief string `json:"spu_brief"` //描述
UpdateTime string `json:"update_time"` //更新时间
}
\ No newline at end of file
......@@ -56,4 +56,11 @@ func ToString(a interface{}) string {
return strconv.FormatFloat(v, 'f', -1, 32)
}
return "change to String error"
}
/**
* 获取联营活动价
*/
func lyActivityPrice() {
}
\ No newline at end of file
package common
type Response struct {
ErrCode int `json:"err_code"`
ErrMsg string `json:"err_msg"`
ErrCode int `json:"err_code"`
ErrMsg string `json:"err_msg"`
Data interface{} `json:"data"`
}
type BomResponse struct {
ErrCode int `json:"err_code"`
ErrMsg string `json:"err_msg"`
Flag int `json:"flag"`
Total int `json:"total"`
ErrCode int `json:"err_code"`
ErrMsg string `json:"err_msg"`
Flag int `json:"flag"`
Total int `json:"total"`
Data interface{} `json:"data"`
}
\ No newline at end of file
}
func GetResponse(errCode int, errMsg string, data interface{}) Response {
return Response{
ErrCode: errCode,
ErrMsg: errMsg,
Data: data,
}
}
......@@ -6,18 +6,27 @@ import (
)
var (
cfg *ini.File
Cfg *ini.File
)
func SetUp(path string) (err error) {
cfg, err = ini.Load(path)
//引入多个文件
Cfg, err = ini.LooseLoad(path+"/config.ini", path+"/search.ini", path+"/redis_key.ini", path+"/rabmq_key.ini")
return
}
func Get(key string) *ini.Key {
if strings.Contains(key, ".") {
keys := strings.Split(key, ".")
return cfg.Section(keys[0]).Key(keys[1])
return Cfg.Section(keys[0]).Key(keys[1])
}
return cfg.Section("").Key(key)
return Cfg.Section("").Key(key)
}
func GetSectionValues(key string) (result []string) {
values := Cfg.Section(key).Keys()
for _, value := range values {
result = append(result, value.String())
}
return result
}
......@@ -24,6 +24,8 @@
#### 1.配置读取
接在```conf/config.ini```文件添加自己的配置项
然后使用```config.Get("xxx.xxx").String()```或者```config.Get("xxx.xxx").Int()```即可
如果想要获取某个节点下的所有值,可以用```config.GetSectionValues("xxx")```
如果想要去获取更多其它的值,可以用暴露出来的配置变量自己去获取,比如: ```config.Cfg.Section("xxx").Key("xxx")```
配置包的文档 : https://ini.unknwon.io/docs
#### 2.mysql连接实例
......
package requests
type QuoteIndexRequest struct {
Keyword string `form:"key_word"`
CheckButton int `form:"check_button"`
SupplierId string `form:"supplier_id"`
Offset int `form:"offset"`
FollowHit int `form:"follow_hit"`
Stock int `form:"stock"`
GoodsNameEq string `form:"goods_name/eq"`
IsExact int `form:"is_exact"`
BrandId string `form:"brand_id"`
AvailRank int `form:"avail_rank"`
SingleRank int `form:"single_rank"`
StockRank int `form:"stock_rank"`
ComRank int `form:"com_rank"`
FirstSearchPage int `form:"first_search_page"`
P int `form:"p"`
Topic int `form:"topic"`
}
......@@ -16,5 +16,8 @@ func InitRouter() *gin.Engine {
r.POST("/search/bom/recommend", controller.Recommend)
r.POST("search/ZiYing/zyh", controller.Zyh)
//快手平台相关
r.GET("/search/quote", controller.QuoteIndex)
return r
}
package service
import (
"fmt"
_ "github.com/tidwall/gjson"
"search_server/model"
"search_server/pkg/gredis"
)
//关键词搜索过期时间
var supplier_over_time = map[string]int64{
"arrow":3600,
"verical":3600,
"mouser":3600,
"master":3600,
"tme":3600,
"buerklin":3600,
}
/*
联营公共类
联营大类,包括修改新增 sku es redis ,推送数据到队列让其他go服务更新数据到mysql
@param goods_list 请求联营格式化后的数据
@param supplier_info 供应商商品详情
*/
func getSkuByGoodsSn(goods_list map[string]*model.LyClearGoodsList,supplier_info *model.SUPPLIER_REDIS_INFO_) map[string]interface{}{
//originGoods := make(map[string]interface{},0)
//
//for goods_sn, goods_list := range goods_list {
// gredis.HGet("")
//
// ladderPrice := make([]*model.TierItem, 0)
//
// productList[goodsSn] = &LyClearGoodsList
//}
//
//fmt.Println(productList)
//return productList
}
/*
新增或者更新redis
*/
func toRedis() {
}
/*
推入队列
*/
func toGoRabmq() {
}
/*
更新es
*/
func toEs() {
}
\ No newline at end of file
package service
import (
"fmt"
"github.com/imroc/req"
"github.com/tidwall/gjson"
"github.com/uniplaces/carbon"
"gopkg.in/olivere/elastic.v5"
"regexp"
"search_server/pkg/config"
"search_server/protopb/bom"
"search_server/requests"
"strings"
)
......@@ -68,7 +71,178 @@ func GetGoodsInfo(goodsIdsStr string) (goodsList []*bom.GoodsModel, err error) {
}
//根据供应商获取商品信息
func GetGoodsInfoBySupplier(supplierId, q, stock int) {
supplierIndex := config.Get("es.search_supplier").String()
fmt.Println(supplierIndex)
func GetGoodsInfoBySupplier(req requests.QuoteIndexRequest) error {
//supplierIndex := config.Get("es.search_supplier").String()
////获取查询条件
//queryString := getSupplierQuery(req)
//res, err := es.CurlES(supplierIndex, queryString)
//if err != nil {
// return err
//}
//fmt.Println(supplierIndex)
return nil
}
func getSupplierIndex(supplierId string) string {
return "temp"
}
func getSupplierQuery(req requests.QuoteIndexRequest) (string, error) {
req.SupplierId = strings.TrimSpace(req.SupplierId)
source := elastic.NewSearchSource()
query := elastic.NewBoolQuery()
//增加联营精确搜索
if req.GoodsNameEq != "" {
var goodsName string
r, _ := regexp.Compile(`/[^A-Za-z0-9]+/u`)
goodsName = r.ReplaceAllString(goodsName, "")
query.Must(elastic.NewTermQuery("auto_goods_name.raw", goodsName))
}
//只显示更新时间在一个月内的数据
oneMonthTimeStamp := carbon.Now().SubMonth().Timestamp()
query.Must(elastic.NewRangeQuery("update_time").Gte(oneMonthTimeStamp))
keyword := strings.ToUpper(req.Keyword)
//判断关键词是否为空
if req.Keyword != "" {
r1, _ := regexp.Compile(`/[\x{4e00}-\x{9fff}]+/u`)
//去除中文?
removeCnKeyword := r1.ReplaceAllString(req.Keyword, "")
r2, _ := regexp.Compile(`/[^A-Za-z0-9]+/`)
req.Keyword = r2.ReplaceAllString(removeCnKeyword, "")
//
if req.IsExact == 1 {
query.Must(elastic.NewTermQuery("auto_goods_name.raw", keyword))
} else {
if req.Keyword != "" {
subQuery := elastic.NewBoolQuery()
subQuery.Should(elastic.NewTermQuery("goods_name", keyword))
subQuery.Should(elastic.NewTermQuery("goods_name_alike", keyword))
query.Must(subQuery)
}
}
req.Keyword = removeCnKeyword
}
//判断是否存在类似物料搜索
//todo:类似索引获取
if true {
query.Should(elastic.NewTermQuery("goods_name_alike", keyword))
}
//根据状态,排除专卖
query.MustNot(elastic.NewTermQuery("status", 10))
//判断库存
if req.Stock > 0 {
query.Must(elastic.NewRangeQuery("stick").Gte(req.Stock))
}
//判断是否要根据品牌id搜索
if req.BrandId != "" {
brandIdSlice := strings.Split(req.BrandId, ",")
query.Must(elastic.NewTermsQuery("brand_id", brandIdSlice))
}
//是否有货
if req.AvailRank == 1 {
query.Must(elastic.NewTermsQuery("sort", 31))
source.Sort("_score", false)
if req.SupplierId == "17" {
source.Sort("update_time", false)
}
source.Sort("stock", false)
source.Sort("single_price", true)
}
//价格排序
if req.SingleRank != 0 {
//todo : 清空排序
source.Sort("single_price_sort", false)
if req.SingleRank == 1 {
source.Sort("single_price", true)
} else if req.SingleRank == 2 {
source.Sort("single_price", false)
}
source.Sort("_score", false)
}
//库存排序
if req.StockRank != 0 {
source.Sort("stock_sort", false)
if req.StockRank == 2 {
source.Sort("stock", true)
}
if req.StockRank == 1 {
source.Sort("stock", false)
}
source.Sort("_score", false)
}
//综合排序
if req.ComRank == 1 {
//todo : 清空排序
source.Sort("status", false)
source.Sort("sort", false)
source.Sort("update_time", false)
source.Sort("stock", false)
source.Sort("single_price", true)
source.Sort("_score", false)
}
//如果什么排序都没有,就开启默认排序
if req.AvailRank == 0 && req.SingleRank == 0 && req.StockRank == 0 && req.ComRank == 0 {
source.Sort("status", false)
source.Sort("sort", false)
source.Sort("update_time", false)
source.Sort("stock", false)
source.Sort("single_price", true)
source.Sort("_score", false)
}
var pageSize, pageCurrent, fromSize int
if req.Offset == 0 {
pageSize = 15
} else {
pageSize = req.Offset
}
if req.P == 0 {
pageCurrent = 15
} else {
pageCurrent = req.P
}
//ES从哪里开始获取数据
fromSize = pageSize * (pageCurrent - 1)
if fromSize+pageSize >= 10000 {
fromSize = 9000
pageSize = 100
}
//搜索过来的分页方式 页码,第一页为2页,接下来以每页5条展示
if (req.FirstSearchPage == 2 || req.P == 2) && req.Topic != 1 && req.Keyword != "" {
pageSize = 2
if req.P != 0 {
pageCurrent = req.P
} else {
pageCurrent = 1
}
fromSize = pageSize * (pageCurrent - 1)
if pageCurrent > 1 {
pageSize = 5
fromSize = pageSize*(pageCurrent-1) - 2 - 1
}
}
source.From(fromSize)
source.Size(pageSize)
//todo : $params['preference'] = '_primary_first';
//判断是否要排除某些品牌
//todo : 待确定需不需要接入
searchRequest := elastic.NewSearchRequest().Source(source)
return searchRequest.Body()
}
This diff could not be displayed because it is too large.
package main
import (
"flag"
"fmt"
"search_server/boot"
"search_server/pkg/config"
)
func main() {
//var path string
//flag.StringVar(&path, "config", "conf/config.ini", "配置文件")
//flag.Parse()
//if err := boot.Boot(path); err != nil {
// log.Error("%s", err)
//}
var path string
flag.StringVar(&path, "configPath", "conf", "配置文件")
flag.Parse()
if err := boot.Boot(path); err != nil {
fmt.Println(err)
}
//fmt.Println(model.GetExcludeBrandIds(1))
fmt.Println(config.GetSectionValues("supplier_all"))
fmt.Println(config.Cfg.Section("xxx").Key("xxx"))
//client := client.
//c := course.NewCourseService("go.micro.api.jtthink.course", client)
//course_rsp, _ := c.ListForTop(context.TODO(), &course.ListRequest{Size: 10})
......
package main
import (
"fmt"
"encoding/json"
)
func main() {
var goodsList []interface{}
var productList map[string]interface{}
var price_temp []interface{}
var tiered []interface{}
m := make(map[string]interface{})
m["goods_names"] = "LM358"
m["stock"] = [...]int64{1,23}
price_temp = append(price_temp,[...]int64{3,5})
m["price_temp"] = price_temp;
s := make(map[string]interface{})
s["purchases"]=1
s["price_us"]=0.66
s["price_us"]=0.67
s["price_cn"]=0.33
tiered = append(tiered,s);
m["tiered"] = tiered;
goodsList = append(goodsList, m)
productList = make(map[string]interface{})
productList["595-LM358BIDR"] = goodsList
productList["595-LM358LVIDDFR"] = goodsList
//map的遍历
for k, v := range productList{
fmt.Println(k,v)
}
jsonStr, err := json.Marshal(productList)
if err!=nil{
return
}
fmt.Printf("%s\n",jsonStr)
}
\ No newline at end of file
package main
import (
"fmt"
"encoding/json"
"search_server/model"
)
func main() {
var LyClearGoodsList model.LyClearGoodsList
LyClearGoodsList.GoodsName = "LM358"
ladderPrice := make([]*model.TierItem, 0)
ladder := model.TierItem{
Purchases: 1,
PriceUs: 0.44,
PriceCn: 1.55,
}
ladderPrice = append(ladderPrice, &ladder)
LyClearGoodsList.Tiered = ladderPrice
var productList map[string]*model.LyClearGoodsList
productList = make(map[string]*model.LyClearGoodsList,0)
productList["595-LM358BIDR"] = &LyClearGoodsList
//map的遍历
for k, v := range productList{
fmt.Println(k,v)
}
jsonStr, err := json.Marshal(productList)
if err!=nil{
return
}
fmt.Printf("%s\n",jsonStr)
}
\ No newline at end of file
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