Commit 13efa80f by mushishixian

添加全局变量中间件

parent 57411840
package middleware
import (
"github.com/gin-gonic/gin"
)
var Context *gin.Context
//将gin的上下文放到全局变量
func ContextVars() gin.HandlerFunc {
return func(c *gin.Context) {
//将gin的上下文放到全局变量
Context = c
c.Next()
}
}
......@@ -12,13 +12,13 @@ func InitRouter() *gin.Engine {
r.Use(gin.Logger())
r.Use(gin.Recovery())
r.Use(middleware.Cors())
r.Use(middleware.ContextVars())
//路由
r.POST("/search/bom/autospu", controller.AutoSpu)
r.POST("/search/bom/recommend", controller.Recommend)
r.POST("search/ZiYing/zyh", controller.Zyh)
r.POST("search/mouser/GetMouserData", controller.GetMouserData)
//快手平台相关
r.GET("/search/quote", controller.QuoteIndex)
r.POST("/search/quote", controller.QuoteIndex)
......
......@@ -54,7 +54,7 @@ func DullDataInfo(r requests.QuoteIndexRequest, goodsListMap map[string]model.Ap
}
//增加类似物料字段
goods = getGoodsAlike(r.Keyword, goods)
result = append(result,goods)
result = append(result, goods)
}
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