Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
杨树贤
/
search_server
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
930b9c90
authored
Jul 06, 2020
by
mushishixian
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
完善json返回
parent
578ce9ad
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
28 deletions
controller/bom_controller.go
model/goods.go
service/goods_service.go
controller/bom_controller.go
View file @
930b9c90
...
@@ -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
...
...
model/goods.go
View file @
930b9c90
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"`
GoodsSn
string
`json:"goods_sn"`
GoodsType
int
`json:"goods_type"`
GoodsType
int
`json:"goods_type"`
SupplierId
int
`json:"supplier_id"`
SupplierId
int
`json:"supplier_id"`
Moq
int
`json:"moq"`
Moq
int
`json:"moq"`
...
@@ -19,10 +20,10 @@ type ApiGoods struct {
...
@@ -19,10 +20,10 @@ type ApiGoods struct {
ClassId1
int
`json:"class_id1"`
ClassId1
int
`json:"class_id1"`
ClassId2
int
`json:"class_id2"`
ClassId2
int
`json:"class_id2"`
Encoded
string
`json:"encoded"`
Encoded
string
`json:"encoded"`
Packing
string
`json:"packing
"`
Packing
string
`json:"packing,omitempty
"`
GoodsUnit
string
`json:"
goods_unit"`
GoodsUnit
string
`json:"goods_unit,
goods_unit"`
GoodsImages
string
`json:"goods_images"`
GoodsImages
string
`json:"goods_images"`
GoodsBrief
string
`json:"goods_brief
"`
GoodsBrief
string
`json:"goods_brief,omitempty
"`
IsBuy
int
`json:"is_buy"`
IsBuy
int
`json:"is_buy"`
Mpl
int
`json:"mpl"`
Mpl
int
`json:"mpl"`
Status
int
`json:"status"`
Status
int
`json:"status"`
...
@@ -31,24 +32,23 @@ type ApiGoods struct {
...
@@ -31,24 +32,23 @@ type ApiGoods struct {
AcType
int
`json:"ac_type"`
AcType
int
`json:"ac_type"`
OtherAttrs
OtherAttrs
`json:"other_attrs"`
OtherAttrs
OtherAttrs
`json:"other_attrs"`
UpdateTime
int
`json:"update_time"`
UpdateTime
int
`json:"update_time"`
SkuName
string
`json:"sku_name
"`
SkuName
string
`json:"sku_name,omitempty
"`
Attrs
Attrs
`json:"attrs"`
Attrs
Attrs
`json:"attrs"`
Cost
string
`json:"cost
"`
Cost
string
`json:"cost,omitempty
"`
NewCost
string
`json:"new_cost
"`
NewCost
string
`json:"new_cost,omitempty
"`
SupplierStock
int
`json:"supplier_stock
"`
SupplierStock
int
`json:"supplier_stock,omitempty
"`
SelfSupplierType
int
`json:"self_supplier_type
"`
SelfSupplierType
int
`json:"self_supplier_type,omitempty
"`
GoodsUnitName
string
`json:"goods_unit_name
"`
GoodsUnitName
string
`json:"goods_unit_name,omitempty
"`
PackingName
string
`json:"packing_name
"`
PackingName
string
`json:"packing_name,omitempty
"`
MpgUnitName
string
`json:"mpg_unit_name
"`
MpgUnitName
string
`json:"mpg_unit_name,omitempty
"`
ScmBrandName
string
`json:"scm_brand_name
"`
ScmBrandName
string
`json:"scm_brand_name,omitempty
"`
AllowCoupon
int
`json:"allow_coupon"`
AllowCoupon
int
`json:"allow_coupon"`
ClassId1Name
string
`json:"class_id1_name"`
ClassId1Name
string
`json:"class_id1_name"`
CLassId2Name
string
`json:"c_lass_id2_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"`
...
@@ -58,19 +58,19 @@ type ApiGoods struct {
...
@@ -58,19 +58,19 @@ type ApiGoods struct {
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
{
...
@@ -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
"`
}
}
service/goods_service.go
View file @
930b9c90
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment