Commit 930b9c90 by mushishixian

完善json返回

parent 578ce9ad
...@@ -9,6 +9,10 @@ import ( ...@@ -9,6 +9,10 @@ import (
//搜索型号 //搜索型号
func AutoSpu(c *gin.Context) { func AutoSpu(c *gin.Context) {
service1:= service.GoodsService{}
res1,_:=service1.GetGoodsInfoByApi("1151005920927710088,1150961641855982990,1150961724815213435")
c.JSON(200,res1)
return
goodsName, _ := c.GetPostForm("goods_name") goodsName, _ := c.GetPostForm("goods_name")
goods := service.AutoSpu(goodsName) goods := service.AutoSpu(goodsName)
var errCode int var errCode int
......
package model package model
type ApiGoods struct { type ApiGoods struct {
PickType int `json:"pick_type"` PickType int `json:"pick_type,omitempty"`
BarCode string `json:"bar_code"` BarCode string `json:"barcode,omitempty"`
GoodsId string `json:"goods_id"` GoodsId string `json:"goods_id"`
GoodsName string `json:"goods_name"` GoodsName string `json:"goods_name"`
GoodsType int `json:"goods_type"` GoodsSn string `json:"goods_sn"`
SupplierId int `json:"supplier_id"` GoodsType int `json:"goods_type"`
Moq int `json:"moq"` SupplierId int `json:"supplier_id"`
Mpq int `json:"mpq"` Moq int `json:"moq"`
Stock int `json:"stock"` Mpq int `json:"mpq"`
HkDeliveryTime string `json:"hk_delivery_time"` Stock int `json:"stock"`
CnDeliveryTime string `json:"cn_delivery_time"` HkDeliveryTime string `json:"hk_delivery_time"`
LadderPrice []LadderPrice `json:"ladder_price"` CnDeliveryTime string `json:"cn_delivery_time"`
BrandName string `json:"brand_name"` LadderPrice []LadderPrice `json:"ladder_price"`
SupplierName string `json:"supplier_name"` BrandName string `json:"brand_name"`
BrandId int `json:"brand_id"` SupplierName string `json:"supplier_name"`
ClassId1 int `json:"class_id1"` BrandId int `json:"brand_id"`
ClassId2 int `json:"class_id2"` ClassId1 int `json:"class_id1"`
Encoded string `json:"encoded"` ClassId2 int `json:"class_id2"`
Packing string `json:"packing"` Encoded string `json:"encoded"`
GoodsUnit string `json:"goods_unit"` Packing string `json:"packing,omitempty"`
GoodsImages string `json:"goods_images"` GoodsUnit string `json:"goods_unit,goods_unit"`
GoodsBrief string `json:"goods_brief"` GoodsImages string `json:"goods_images"`
IsBuy int `json:"is_buy"` GoodsBrief string `json:"goods_brief,omitempty"`
Mpl int `json:"mpl"` IsBuy int `json:"is_buy"`
Status int `json:"status"` Mpl int `json:"mpl"`
Pdf string `json:"pdf"` Status int `json:"status"`
Encap string `json:"encap"` Pdf string `json:"pdf"`
AcType int `json:"ac_type"` Encap string `json:"encap"`
OtherAttrs OtherAttrs `json:"other_attrs"` AcType int `json:"ac_type"`
UpdateTime int `json:"update_time"` OtherAttrs OtherAttrs `json:"other_attrs"`
SkuName string `json:"sku_name"` UpdateTime int `json:"update_time"`
Attrs Attrs `json:"attrs"` SkuName string `json:"sku_name,omitempty"`
Cost string `json:"cost"` Attrs Attrs `json:"attrs"`
NewCost string `json:"new_cost"` Cost string `json:"cost,omitempty"`
SupplierStock int `json:"supplier_stock"` NewCost string `json:"new_cost,omitempty"`
SelfSupplierType int `json:"self_supplier_type"` SupplierStock int `json:"supplier_stock,omitempty"`
GoodsUnitName string `json:"goods_unit_name"` SelfSupplierType int `json:"self_supplier_type,omitempty"`
PackingName string `json:"packing_name"` GoodsUnitName string `json:"goods_unit_name,omitempty"`
MpgUnitName string `json:"mpg_unit_name"` PackingName string `json:"packing_name,omitempty"`
ScmBrandName string `json:"scm_brand_name"` MpgUnitName string `json:"mpg_unit_name,omitempty"`
AllowCoupon int `json:"allow_coupon"` ScmBrandName string `json:"scm_brand_name,omitempty"`
ClassId1Name string `json:"class_id1_name"` AllowCoupon int `json:"allow_coupon"`
CLassId2Name string `json:"c_lass_id2_name"` ClassId1Name string `json:"class_id1_name"`
CLassId2Name string `json:"c_lass_id2_name"`
SpuId string `json:"spu_id,omitempty"` SpuId string `json:"spu_id,omitempty"`
BatchSn string `json:"batch_sn,omitempty"` BatchSn string `json:"batch_sn,omitempty"`
Canal string `json:"canal,omitempty"` Canal string `json:"canal,omitempty"`
CpTime int `json:"cp_time,omitempty"` CpTime int `json:"cp_time"`
Coefficient Coefficient `json:"coefficient,omitempty"` Coefficient Coefficient `json:"coefficient,omitempty"`
OriginalPrice []OriginalPrice `json:"original_price,omitempty"` OriginalPrice []OriginalPrice `json:"original_price,omitempty"`
SuppExtendFee SuppExtendFee `json:"supp_extend_fee,omitempty"` SuppExtendFee SuppExtendFee `json:"supp_extend_fee,omitempty"`
ClassId3 int `json:"class_id3,omitempty"` ClassId3 int `json:"class_id3,omitempty"`
SpuName string `json:"spu_name,omitempty"` SpuName string `json:"spu_name,omitempty"`
ImagesL string `json:"images_l,omitempty"` ImagesL string `json:"images_l,omitempty"`
SpuBrief string `json:"spu_brief,omitempty"` SpuBrief string `json:"spu_brief,omitempty"`
SpuDetail string `json:"spu_detail,omitempty"` SpuDetail string `json:"spu_detail,omitempty"`
ClassName3 string `json:"class_name3,omitempty"` ClassName3 string `json:"class_name3,omitempty"`
ErpTax bool `json:"erp_tax,omitempty"` ErpTax bool `json:"erp_tax"`
ScmBrand ScmBrand `json:"scm_brand,omitempty"` ScmBrand ScmBrand `json:"scm_brand,omitempty"`
} }
type Attr struct { type Attr struct {
AttrName string AttrName string `json:"attr_name,omitempty"`
AttrValue string AttrValue string `json:"attr_value,omitempty"`
} }
type Attrs map[string]Attr type Attrs map[string]Attr
type OtherAttrs struct { type OtherAttrs struct {
GrossWeight string `json:"gross_weight"` GrossWeight string `json:"gross_weight,omitempty"`
} }
type LadderPrice struct { type LadderPrice struct {
Purchases int `json:"purchases"` Purchases int `json:"purchases"`
PriceUs float64 `json:"price_us"` PriceUs float64 `json:"price_us"`
PriceCn float64 `json:"price_cn"` PriceCn float64 `json:"price_cn"`
PriceAc float64 `json:"price_ac"` PriceAc float64 `json:"price_ac"`
...@@ -99,14 +99,14 @@ type SuppExtendFee struct { ...@@ -99,14 +99,14 @@ type SuppExtendFee struct {
Max int `json:"max"` Max int `json:"max"`
Price float64 `json:"price"` Price float64 `json:"price"`
} `json:"cn,omitempty"` } `json:"cn,omitempty"`
Hk struct{ Hk struct {
Max int `json:"max"` Max int `json:"max"`
Price float64 `json:"price"` Price float64 `json:"price"`
} `json:"hk,omitempty"` } `json:"hk,omitempty"`
} }
type ScmBrand struct { type ScmBrand struct {
ErpBrandName string `json:"erp_brand_name"` ErpBrandName string `json:"erp_brand_name,omitempty"`
ErpBrandId string `json:"erp_brand_id"` ErpBrandId string `json:"erp_brand_id,omitempty"`
ScmBrandId string `json:"scm_brand_id"` ScmBrandId string `json:"scm_brand_id,omitempty"`
} }
...@@ -9,7 +9,6 @@ import ( ...@@ -9,7 +9,6 @@ import (
"gopkg.in/olivere/elastic.v5" "gopkg.in/olivere/elastic.v5"
"regexp" "regexp"
"search_server/model" "search_server/model"
"search_server/pkg/common"
"search_server/pkg/config" "search_server/pkg/config"
"search_server/pkg/es" "search_server/pkg/es"
"search_server/pkg/gredis" "search_server/pkg/gredis"
...@@ -66,6 +65,7 @@ func CurlGoodsInfo(goodsIdsStr string, params req.Param) (goodsList []*model.Api ...@@ -66,6 +65,7 @@ func CurlGoodsInfo(goodsIdsStr string, params req.Param) (goodsList []*model.Api
goods.BarCode = data.Get("bar_code").String() goods.BarCode = data.Get("bar_code").String()
goods.GoodsId = data.Get("goods_id").String() goods.GoodsId = data.Get("goods_id").String()
goods.GoodsName = data.Get("goods_name").String() goods.GoodsName = data.Get("goods_name").String()
goods.GoodsSn = data.Get("goods_sn").String()
goods.GoodsType = int(data.Get("goods_type").Int()) goods.GoodsType = int(data.Get("goods_type").Int())
goods.SupplierId = int(data.Get("supplier_id").Int()) goods.SupplierId = int(data.Get("supplier_id").Int())
goods.Mpq = int(data.Get("mpq").Int()) goods.Mpq = int(data.Get("mpq").Int())
...@@ -133,13 +133,12 @@ func CurlGoodsInfo(goodsIdsStr string, params req.Param) (goodsList []*model.Api ...@@ -133,13 +133,12 @@ func CurlGoodsInfo(goodsIdsStr string, params req.Param) (goodsList []*model.Api
//Attrs //Attrs
attrMap := make(map[string]model.Attr, 0) attrMap := make(map[string]model.Attr, 0)
for key, attr := range data.Get("attrs").Array() { for key, attr := range data.Get("attrs").Map() {
attr := model.Attr{ attr := model.Attr{
AttrName: attr.Get("attr_name").String(), AttrName: attr.Get("attr_name").String(),
AttrValue: attr.Get("attr_value").String(), AttrValue: attr.Get("attr_value").String(),
} }
attrMap[key] = attr
attrMap[common.ToString(key)] = attr
} }
goods.Attrs = attrMap goods.Attrs = attrMap
......
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