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
4714c1e0
authored
Jul 20, 2020
by
mushishixian
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
优化
parent
3f5b1808
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
6 additions
and
8 deletions
middleware/cors.go
service/bom_service.go
service/goods_service.go
middleware/cors.go
View file @
4714c1e0
...
...
@@ -9,6 +9,7 @@ import (
func
Cors
()
gin
.
HandlerFunc
{
corsDomain
:=
config
.
Get
(
"web.cors_domain"
)
.
Strings
(
","
)
corsDomain
=
append
(
corsDomain
,
"https://bom.ichunt.com"
)
return
cors
.
New
(
cors
.
Config
{
AllowOrigins
:
corsDomain
,
AllowMethods
:
[]
string
{
"POST"
,
"GET"
,
"PUT"
,
"DELETE"
},
...
...
service/bom_service.go
View file @
4714c1e0
...
...
@@ -170,7 +170,7 @@ func getBomTermQuery(goodsName, brandName string, number int, isRawSearch bool)
if
isRawSearch
{
source
.
Size
(
100
)
}
else
{
source
.
Size
(
1
)
source
.
Size
(
50
)
}
source
.
Sort
(
"_score"
,
false
)
.
Sort
(
"sort"
,
false
)
.
Sort
(
"single_price"
,
true
)
queryRequest
:=
elastic
.
NewSearchRequest
()
.
Source
(
source
)
...
...
service/goods_service.go
View file @
4714c1e0
package
service
import
(
"fmt"
"github.com/gomodule/redigo/redis"
"github.com/imroc/req"
"github.com/tidwall/gjson"
...
...
@@ -122,11 +121,11 @@ func CurlGoodsInfo(goodsIdsStr string, params req.Param) (goodsList []model.ApiG
ladderPrice
:=
make
([]
model
.
LadderPrice
,
0
)
for
_
,
price
:=
range
data
.
Get
(
"ladder_price"
)
.
Array
()
{
ladder
:=
model
.
LadderPrice
{
Purchases
:
int
(
price
.
Get
(
"purchases"
)
.
Int
()),
Purchases
:
int
(
price
.
Get
(
"purchases"
)
.
Int
()),
PurchasesStr
:
int
(
price
.
Get
(
"purchases"
)
.
Int
()),
PriceUs
:
price
.
Get
(
"price_us"
)
.
Float
(),
PriceCn
:
price
.
Get
(
"price_cn"
)
.
Float
(),
PriceAc
:
price
.
Get
(
"price_ac"
)
.
Float
(),
PriceUs
:
price
.
Get
(
"price_us"
)
.
Float
(),
PriceCn
:
price
.
Get
(
"price_cn"
)
.
Float
(),
PriceAc
:
price
.
Get
(
"price_ac"
)
.
Float
(),
}
ladderPrice
=
append
(
ladderPrice
,
ladder
)
}
...
...
@@ -238,7 +237,6 @@ func GetGoodsIdsByEs(res string) (goodsIds []string) {
for
_
,
item
:=
range
gjArray
{
goodsIds
=
append
(
goodsIds
,
item
.
String
())
}
fmt
.
Println
(
goodsIds
)
return
}
...
...
@@ -248,6 +246,5 @@ func GetGoodsIdsByEsMsearch(res string) (goodsIds []string) {
for
_
,
item
:=
range
gjArray
{
goodsIds
=
append
(
goodsIds
,
item
.
String
())
}
fmt
.
Println
(
goodsIds
)
return
}
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