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
88ad28cd
authored
Jun 30, 2020
by
huangchengyi
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
1.0
parent
b85fddcc
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
1 deletions
cmd/test1.go
service/mouser_service.go
cmd/test1.go
0 → 100644
View file @
88ad28cd
package
main
import
(
"github.com/gin-gonic/gin"
"search_server/framework/gin_"
"search_server/protopb/mouser"
"search_server/service"
)
func
main
()
{
MouserService
:=
service
.
NewMouserServiceImpl
()
rsp
:=
&
mouser
.
MouserResponse
{}
err
=
MouserService
.
MouserGetData
(
*
gin
.
Context
,
request
.
(
*
mouser
.
MouserRequest
),
rsp
)
return
rsp
,
err
}
//处理请求
func
MouserGetData
(
c
*
service
.
MouserServiceImpl
)
gin_
.
Endpoint
{
rsp
:=
&
mouser
.
MouserResponse
{}
err
=
c
.
MouserGetData
(
context
,
request
.
(
*
mouser
.
MouserRequest
),
rsp
)
return
rsp
,
err
}
\ No newline at end of file
service/mouser_service.go
View file @
88ad28cd
...
...
@@ -11,6 +11,8 @@ import (
"search_server/protopb/mouser"
"strings"
)
//mouser外链网址
const
Mouser_api_url
string
=
"https://www.masterelectronics.com/wst/MSI005ws.asmx/GeneralSearch?InStock=0&ExactMatch=0&username=MSI005&password=MSI005@ME"
//单例
type
MouserServiceImpl
struct
{}
...
...
@@ -30,8 +32,9 @@ func (bs *MouserServiceImpl) MouserGetData(ctx context.Context, req *mouser.Mous
//mouser请求外链
func
OutLink
(
goodsName
string
)
[]
string
{
Mouser_api_urls
:=
Mouser_api_url
+
"&Query="
+
goodsName
+
"&Limit=25"
;
print
(
"nini"
)
print
(
Mouser_api_urls
)
os
.
Exit
(
1
)
replace
,
_
:=
regexp
.
Compile
(
"[^A-Za-z0-9]+"
)
goodsName
=
replace
.
ReplaceAllString
(
goodsName
,
""
)
...
...
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