Commit 4714c1e0 by mushishixian

优化

parent 3f5b1808
...@@ -9,6 +9,7 @@ import ( ...@@ -9,6 +9,7 @@ import (
func Cors() gin.HandlerFunc { func Cors() gin.HandlerFunc {
corsDomain := config.Get("web.cors_domain").Strings(",") corsDomain := config.Get("web.cors_domain").Strings(",")
corsDomain = append(corsDomain, "https://bom.ichunt.com")
return cors.New(cors.Config{ return cors.New(cors.Config{
AllowOrigins: corsDomain, AllowOrigins: corsDomain,
AllowMethods: []string{"POST", "GET", "PUT", "DELETE"}, AllowMethods: []string{"POST", "GET", "PUT", "DELETE"},
......
...@@ -170,7 +170,7 @@ func getBomTermQuery(goodsName, brandName string, number int, isRawSearch bool) ...@@ -170,7 +170,7 @@ func getBomTermQuery(goodsName, brandName string, number int, isRawSearch bool)
if isRawSearch { if isRawSearch {
source.Size(100) source.Size(100)
} else { } else {
source.Size(1) source.Size(50)
} }
source.Sort("_score", false).Sort("sort", false).Sort("single_price", true) source.Sort("_score", false).Sort("sort", false).Sort("single_price", true)
queryRequest := elastic.NewSearchRequest().Source(source) queryRequest := elastic.NewSearchRequest().Source(source)
......
package service package service
import ( import (
"fmt"
"github.com/gomodule/redigo/redis" "github.com/gomodule/redigo/redis"
"github.com/imroc/req" "github.com/imroc/req"
"github.com/tidwall/gjson" "github.com/tidwall/gjson"
...@@ -122,11 +121,11 @@ func CurlGoodsInfo(goodsIdsStr string, params req.Param) (goodsList []model.ApiG ...@@ -122,11 +121,11 @@ func CurlGoodsInfo(goodsIdsStr string, params req.Param) (goodsList []model.ApiG
ladderPrice := make([]model.LadderPrice, 0) ladderPrice := make([]model.LadderPrice, 0)
for _, price := range data.Get("ladder_price").Array() { for _, price := range data.Get("ladder_price").Array() {
ladder := model.LadderPrice{ ladder := model.LadderPrice{
Purchases: int(price.Get("purchases").Int()), Purchases: int(price.Get("purchases").Int()),
PurchasesStr: int(price.Get("purchases").Int()), PurchasesStr: int(price.Get("purchases").Int()),
PriceUs: price.Get("price_us").Float(), PriceUs: price.Get("price_us").Float(),
PriceCn: price.Get("price_cn").Float(), PriceCn: price.Get("price_cn").Float(),
PriceAc: price.Get("price_ac").Float(), PriceAc: price.Get("price_ac").Float(),
} }
ladderPrice = append(ladderPrice, ladder) ladderPrice = append(ladderPrice, ladder)
} }
...@@ -238,7 +237,6 @@ func GetGoodsIdsByEs(res string) (goodsIds []string) { ...@@ -238,7 +237,6 @@ func GetGoodsIdsByEs(res string) (goodsIds []string) {
for _, item := range gjArray { for _, item := range gjArray {
goodsIds = append(goodsIds, item.String()) goodsIds = append(goodsIds, item.String())
} }
fmt.Println(goodsIds)
return return
} }
...@@ -248,6 +246,5 @@ func GetGoodsIdsByEsMsearch(res string) (goodsIds []string) { ...@@ -248,6 +246,5 @@ func GetGoodsIdsByEsMsearch(res string) (goodsIds []string) {
for _, item := range gjArray { for _, item := range gjArray {
goodsIds = append(goodsIds, item.String()) goodsIds = append(goodsIds, item.String())
} }
fmt.Println(goodsIds)
return return
} }
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