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
4f331a22
authored
Jun 17, 2020
by
mushishixian
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
锁定结果排序
parent
057d86dd
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
34 deletions
conf/config.ini
service/goods_service.go
conf/config.ini
View file @
4f331a22
...
...
@@ -15,7 +15,7 @@ urls = http://192.168.2.232:9200,http://192.168.2.232:9200
index_name
=
future,rochester,tme,verical,element14,digikey,chip1stop,aipco,arrow,alliedelec,avnet,mouser,zhuanmai,peigenesis,powell,rs,buerklin,liexin_ziying
search_supplier
=
future,rochester,tme,verical,element14,digikey,chip1stop,aipco,arrow,alliedelec,avnet,mouser,peigenesis,powell,rs,buerklin,zhuanmai
hk_delivery_type_supplier
=
future,rochester,tme,verical,element14,digikey,chip1stop,aipco,arrow,alliedelec,avnet,mouser,peigenesis,powell,rs,buerklin
attr_index
=
goods_map
2
attr_index
=
goods_map
[database]
user_name
=
root
...
...
service/goods_service.go
View file @
4f331a22
...
...
@@ -5,6 +5,7 @@ import (
"github.com/tidwall/gjson"
"search_server/pkg/config"
"search_server/protopb/bom"
"strings"
)
func
GetGoodsInfo
(
goodsIdsStr
string
)
(
goodsList
[]
*
bom
.
GoodsModel
,
err
error
)
{
...
...
@@ -19,41 +20,47 @@ func GetGoodsInfo(goodsIdsStr string) (goodsList []*bom.GoodsModel, err error) {
}
//先判断返回的data是不是字典,不是字典代表可能是返回字符串了
if
gjson
.
Get
(
resp
.
String
(),
"data"
)
.
IsObject
()
{
for
_
,
data
:=
range
gjson
.
Get
(
resp
.
String
(),
"data"
)
.
Map
()
{
//还要去判断是否是bool
if
data
.
IsObject
()
{
var
goods
bom
.
GoodsModel
goods
.
GoodsName
=
data
.
Get
(
"goods_name"
)
.
String
()
goods
.
GoodsId
=
data
.
Get
(
"goods_id"
)
.
String
()
goods
.
BrandId
=
data
.
Get
(
"goods_id"
)
.
Int
()
goods
.
Pdf
=
data
.
Get
(
"pdf"
)
.
String
()
goods
.
Stock
=
data
.
Get
(
"stock"
)
.
Int
()
goods
.
Mpq
=
data
.
Get
(
"mpq"
)
.
Int
()
goods
.
Moq
=
data
.
Get
(
"moq"
)
.
Int
()
goods
.
SupplierName
=
data
.
Get
(
"supplier_name"
)
.
String
()
goods
.
BrandName
=
data
.
Get
(
"brand_name"
)
.
String
()
goods
.
HkDeliveryType
=
data
.
Get
(
"hk_delivery_time"
)
.
String
()
goods
.
CnDeliveryTime
=
data
.
Get
(
"cn_delivery_time"
)
.
String
()
goods
.
IsBuy
=
data
.
Get
(
"is_buy"
)
.
Int
()
goods
.
Mpl
=
data
.
Get
(
"mpl"
)
.
Int
()
goods
.
Encap
=
data
.
Get
(
"encap"
)
.
String
()
goods
.
SupplierId
=
data
.
Get
(
"supplier_id"
)
.
Int
()
goods
.
Status
=
data
.
Get
(
"status"
)
.
Int
()
goods
.
GoodsType
=
data
.
Get
(
"goods_type"
)
.
Int
()
goods
.
AcType
=
data
.
Get
(
"ac_type"
)
.
Int
()
var
ladderPrice
[]
*
bom
.
LADDER_PRICE
for
_
,
price
:=
range
data
.
Get
(
"ladder_price"
)
.
Array
()
{
var
ladder
bom
.
LADDER_PRICE
ladder
=
bom
.
LADDER_PRICE
{
Purchases
:
price
.
Get
(
"purchases"
)
.
Int
(),
PriceUs
:
float32
(
price
.
Get
(
"price_us"
)
.
Float
()),
PriceCn
:
float32
(
price
.
Get
(
"price_cn"
)
.
Float
()),
PriceAc
:
float32
(
price
.
Get
(
"price_ac"
)
.
Float
()),
//排序操作
goodsIdList
:=
strings
.
Split
(
goodsIdsStr
,
","
)
for
_
,
goodsId
:=
range
goodsIdList
{
for
_
,
data
:=
range
gjson
.
Get
(
resp
.
String
(),
"data"
)
.
Map
()
{
if
goodsId
==
data
.
Get
(
"goods_id"
)
.
String
()
{
//还要去判断是否是bool
if
data
.
IsObject
()
{
var
goods
bom
.
GoodsModel
goods
.
GoodsName
=
data
.
Get
(
"goods_name"
)
.
String
()
goods
.
GoodsId
=
data
.
Get
(
"goods_id"
)
.
String
()
goods
.
BrandId
=
data
.
Get
(
"goods_id"
)
.
Int
()
goods
.
Pdf
=
data
.
Get
(
"pdf"
)
.
String
()
goods
.
Stock
=
data
.
Get
(
"stock"
)
.
Int
()
goods
.
Mpq
=
data
.
Get
(
"mpq"
)
.
Int
()
goods
.
Moq
=
data
.
Get
(
"moq"
)
.
Int
()
goods
.
SupplierName
=
data
.
Get
(
"supplier_name"
)
.
String
()
goods
.
BrandName
=
data
.
Get
(
"brand_name"
)
.
String
()
goods
.
HkDeliveryType
=
data
.
Get
(
"hk_delivery_time"
)
.
String
()
goods
.
CnDeliveryTime
=
data
.
Get
(
"cn_delivery_time"
)
.
String
()
goods
.
IsBuy
=
data
.
Get
(
"is_buy"
)
.
Int
()
goods
.
Mpl
=
data
.
Get
(
"mpl"
)
.
Int
()
goods
.
Encap
=
data
.
Get
(
"encap"
)
.
String
()
goods
.
SupplierId
=
data
.
Get
(
"supplier_id"
)
.
Int
()
goods
.
Status
=
data
.
Get
(
"status"
)
.
Int
()
goods
.
GoodsType
=
data
.
Get
(
"goods_type"
)
.
Int
()
goods
.
AcType
=
data
.
Get
(
"ac_type"
)
.
Int
()
var
ladderPrice
[]
*
bom
.
LADDER_PRICE
for
_
,
price
:=
range
data
.
Get
(
"ladder_price"
)
.
Array
()
{
var
ladder
bom
.
LADDER_PRICE
ladder
=
bom
.
LADDER_PRICE
{
Purchases
:
price
.
Get
(
"purchases"
)
.
Int
(),
PriceUs
:
float32
(
price
.
Get
(
"price_us"
)
.
Float
()),
PriceCn
:
float32
(
price
.
Get
(
"price_cn"
)
.
Float
()),
PriceAc
:
float32
(
price
.
Get
(
"price_ac"
)
.
Float
()),
}
ladderPrice
=
append
(
ladderPrice
,
&
ladder
)
}
goods
.
LadderPrice
=
ladderPrice
goodsList
=
append
(
goodsList
,
&
goods
)
}
ladderPrice
=
append
(
ladderPrice
,
&
ladder
)
}
goods
.
LadderPrice
=
ladderPrice
goodsList
=
append
(
goodsList
,
&
goods
)
}
}
}
...
...
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