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
13efa80f
authored
Jul 08, 2020
by
mushishixian
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
添加全局变量中间件
parent
57411840
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
2 deletions
middleware/context_vars.go
routes/router.go
service/transformer/goods_transformer.go
middleware/context_vars.go
0 → 100644
View file @
13efa80f
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
()
}
}
routes/router.go
View file @
13efa80f
...
...
@@ -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
)
...
...
service/transformer/goods_transformer.go
View file @
13efa80f
...
...
@@ -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
}
...
...
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