Commit d10da03d by mushishixian

修复优化

parent 0773d030
* *
!.gitignore !.gitignoregit
\ No newline at end of file \ No newline at end of file
[web]
port = 9000
mode = debug
[message]
api_domain = http://api.ichunt.com/msg/sendMessageByAuto
api_md5_str = fh6y5t4rr351d2c3bryi
[goods]
api_url = http://192.168.2.232:60004
[es]
url = http://192.168.2.232:9200
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
[database]
user_name = root
password = root
host = 192.168.2.239
database = test
table_prefix =
type = mysql
[redis]
write_host = 192.168.1.235:6379
read_host = 192.168.1.235:6379
write_password = icDb29mLy2s
read_password = icDb29mLy2s
max_idle = 10
max_active = 10
idle_timeout = 20
[mongo]
host = 127.0.0.1:27017
database = liexin_config
\ No newline at end of file
...@@ -4,6 +4,7 @@ import ( ...@@ -4,6 +4,7 @@ import (
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"net/http" "net/http"
"search_server/framework/gin_" "search_server/framework/gin_"
"search_server/pkg/config"
) )
//放 通用中间件 //放 通用中间件
...@@ -21,7 +22,11 @@ func Cors_Middleware() gin_.Middleware { ...@@ -21,7 +22,11 @@ func Cors_Middleware() gin_.Middleware {
return func(next gin_.Endpoint) gin_.Endpoint { return func(next gin_.Endpoint) gin_.Endpoint {
return func(c *gin.Context, request interface{}) (response interface{}, err error) { return func(c *gin.Context, request interface{}) (response interface{}, err error) {
method := c.Request.Method method := c.Request.Method
c.Header("Access-Control-Allow-Origin", "*") corsDomains := config.Get("web.cors.domain").Strings(",")
for _, domain := range corsDomains {
c.Header("Access-Control-Allow-Origin", domain)
}
c.Header("Access-Control-Allow-Origin", "http://bom.liexin.com")
c.Header("Access-Control-Allow-Headers", "Content-Type,AccessToken,X-CSRF-Token, Authorization, Token") c.Header("Access-Control-Allow-Headers", "Content-Type,AccessToken,X-CSRF-Token, Authorization, Token")
c.Header("Access-Control-Allow-Methods", "POST, GET, OPTIONS") c.Header("Access-Control-Allow-Methods", "POST, GET, OPTIONS")
c.Header("Access-Control-Expose-Headers", "Content-Length, Access-Control-Allow-Origin, Access-Control-Allow-Headers, Content-Type") c.Header("Access-Control-Expose-Headers", "Content-Length, Access-Control-Allow-Origin, Access-Control-Allow-Headers, Content-Type")
......
...@@ -3,21 +3,29 @@ module search_server ...@@ -3,21 +3,29 @@ module search_server
go 1.14 go 1.14
require ( require (
github.com/gin-contrib/cors v1.3.1
github.com/gin-gonic/gin v1.6.3 github.com/gin-gonic/gin v1.6.3
github.com/go-ini/ini v1.44.0 github.com/go-ini/ini v1.44.0
github.com/go-kratos/kratos v0.5.0 github.com/gogo/protobuf v1.3.1 // indirect
github.com/golang/protobuf v1.4.2 github.com/golang/protobuf v1.4.2
github.com/gomodule/redigo v2.0.1-0.20180401191855-9352ab68be13+incompatible github.com/gomodule/redigo v2.0.1-0.20180401191855-9352ab68be13+incompatible
github.com/gopherjs/gopherjs v0.0.0-20181103185306-d547d1d9531e // indirect github.com/gopherjs/gopherjs v0.0.0-20181103185306-d547d1d9531e // indirect
github.com/gorilla/websocket v1.4.2 // indirect
github.com/grpc-ecosystem/go-grpc-middleware v1.2.0 // indirect
github.com/grpc-ecosystem/grpc-gateway v1.14.3 // indirect
github.com/ichunt2019/logger v1.0.5 github.com/ichunt2019/logger v1.0.5
github.com/imroc/req v0.3.0 github.com/imroc/req v0.3.0
github.com/jinzhu/gorm v1.9.12 github.com/jinzhu/gorm v1.9.12
github.com/micro/go-micro/v2 v2.5.0 github.com/micro/go-micro/v2 v2.5.0
github.com/prometheus/client_golang v1.5.1 // indirect
github.com/prometheus/common v0.9.1 github.com/prometheus/common v0.9.1
github.com/prometheus/procfs v0.0.11 // indirect
github.com/sirupsen/logrus v1.5.0 // indirect
github.com/smartystreets/goconvey v1.6.4 // indirect github.com/smartystreets/goconvey v1.6.4 // indirect
github.com/stretchr/testify v1.5.1 // indirect github.com/stretchr/testify v1.5.1 // indirect
github.com/syyongx/php2go v0.9.4 github.com/syyongx/php2go v0.9.4
github.com/tidwall/gjson v1.6.0 github.com/tidwall/gjson v1.6.0
go.uber.org/zap v1.14.1 // indirect
golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2 // indirect golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2 // indirect
golang.org/x/sys v0.0.0-20200523222454-059865788121 // indirect golang.org/x/sys v0.0.0-20200523222454-059865788121 // indirect
google.golang.org/genproto v0.0.0-20200527145253-8367513e4ece // indirect google.golang.org/genproto v0.0.0-20200527145253-8367513e4ece // indirect
...@@ -25,6 +33,7 @@ require ( ...@@ -25,6 +33,7 @@ require (
gopkg.in/ini.v1 v1.51.0 // indirect gopkg.in/ini.v1 v1.51.0 // indirect
gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22 gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22
gopkg.in/olivere/elastic.v5 v5.0.85 gopkg.in/olivere/elastic.v5 v5.0.85
sigs.k8s.io/yaml v1.2.0 // indirect
) )
replace google.golang.org/grpc => google.golang.org/grpc v1.26.0 replace google.golang.org/grpc => google.golang.org/grpc v1.26.0
...@@ -27,12 +27,7 @@ func (bs *BomServiceImpl) Recommend(ctx context.Context, req *bom.RecommendReque ...@@ -27,12 +27,7 @@ func (bs *BomServiceImpl) Recommend(ctx context.Context, req *bom.RecommendReque
rsp.ErrorMessage = "参数不全" rsp.ErrorMessage = "参数不全"
return nil return nil
} }
recommendData := Recommend(req) rsp.Data = Recommend(req)
if recommendData.Total == 0 {
rsp.Data = nil
} else {
rsp.Data = recommendData
}
return nil return nil
} }
......
...@@ -46,10 +46,9 @@ func GetGoodsInfo(goodsIdsStr string) (goodsList []*bom.GoodsModel, err error) { ...@@ -46,10 +46,9 @@ func GetGoodsInfo(goodsIdsStr string) (goodsList []*bom.GoodsModel, err error) {
goods.Status = data.Get("status").Int() goods.Status = data.Get("status").Int()
goods.GoodsType = data.Get("goods_type").Int() goods.GoodsType = data.Get("goods_type").Int()
goods.AcType = data.Get("ac_type").Int() goods.AcType = data.Get("ac_type").Int()
var ladderPrice []*bom.LadderPrice ladderPrice := make([]*bom.LadderPrice, 0)
for _, price := range data.Get("ladder_price").Array() { for _, price := range data.Get("ladder_price").Array() {
var ladder bom.LadderPrice ladder := bom.LadderPrice{
ladder = bom.LadderPrice{
Purchases: price.Get("purchases").Int(), Purchases: price.Get("purchases").Int(),
PriceUs: float32(price.Get("price_us").Float()), PriceUs: float32(price.Get("price_us").Float()),
PriceCn: float32(price.Get("price_cn").Float()), PriceCn: float32(price.Get("price_cn").Float()),
......
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