Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
杨树贤
/
LC_soapi
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
902c9278
authored
Jan 08, 2020
by
杨树贤
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
整理代码
parent
0c95ad35
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
39 additions
and
25 deletions
go.mod
go.sum
routers/router.go
server/hrpc/self.go
controller/self.go → server/http/self.go
service/self_service/self.go → service/self.go
go.mod
View file @
902c9278
...
...
@@ -8,6 +8,7 @@ require (
github.com/go-ini/ini v1.51.1
github.com/go-playground/universal-translator v0.17.0 // indirect
github.com/go-redis/redis/v7 v7.0.0-beta.5
github.com/hprose/hprose-golang v2.0.4+incompatible
github.com/ichunt2019/logger v1.0.5
github.com/json-iterator/go v1.1.9 // indirect
github.com/leodido/go-urn v1.2.0 // indirect
...
...
go.sum
View file @
902c9278
...
...
@@ -58,6 +58,8 @@ github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
github.com/gopherjs/gopherjs v0.0.0-20181103185306-d547d1d9531e/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
github.com/hprose/hprose-golang v2.0.4+incompatible h1:xUZLSShgv5+KCfK3RCsac8DyWKxBPt9hH3KK3TA1f0c=
github.com/hprose/hprose-golang v2.0.4+incompatible/go.mod h1:FfwwCUQFF3f5t03SrzdSghXVZkC01uEJS6Xwzcz0NOo=
github.com/ichunt2019/logger v1.0.5 h1:85C6kJCH9xlbLt1VmwHp/8iScm+bIlenK6nanWwwq/o=
github.com/ichunt2019/logger v1.0.5/go.mod h1:5IWMrrqJIWwOIGav9ACWOI+KOuYeteUvOei4zubclwg=
github.com/jinzhu/gorm v0.0.0-20180213101209-6e1387b44c64 h1:8I4kQ5M5OjZKNsgRUs20soTdIoo1GbiGApV31kJ9e6Y=
...
...
routers/router.go
View file @
902c9278
package
routers
import
(
"LC_soapi/controller"
"LC_soapi/pkg/setting"
"LC_soapi/server/hrpc"
"LC_soapi/server/http"
"github.com/gin-gonic/gin"
"github.com/hprose/hprose-golang/rpc"
)
func
InitRouter
()
*
gin
.
Engine
{
r
:=
gin
.
New
()
r
:=
gin
.
Default
()
r
.
Use
(
gin
.
Logger
())
r
.
Use
(
gin
.
Recovery
())
gin
.
SetMode
(
setting
.
ServerSetting
.
RunMode
)
apiSelf
:=
r
.
Group
(
"/api/self"
)
apiSelf
:=
r
.
Group
(
"/api"
)
{
//自营搜索
apiSelf
.
GET
(
"/se
arch"
,
controller
.
Search
)
apiSelf
.
GET
(
"/se
lf/search"
,
http
.
Search
)
}
r
.
GET
(
"/test"
,
func
(
c
*
gin
.
Context
)
{
c
.
JSON
(
200
,
gin
.
H
{
"message"
:
"test"
,
})
//hprose服务
service
:=
rpc
.
NewHTTPService
()
service
.
AddInstanceMethods
(
&
hrpc
.
SelfServer
{})
r
.
Any
(
"/hprose"
,
func
(
c
*
gin
.
Context
)
{
service
.
Debug
=
true
service
.
ErrorDelay
=
0
service
.
ServeHTTP
(
c
.
Writer
,
c
.
Request
)
})
return
r
...
...
server/hrpc/self.go
0 → 100644
View file @
902c9278
package
hrpc
type
SelfServer
struct
{
}
func
(
s
*
SelfServer
)
Search
()
{
}
controller
/self.go
→
server/http
/self.go
View file @
902c9278
package
controller
package
http
import
(
"LC_soapi/pkg/app"
"LC_soapi/service/self_service"
"fmt"
"LC_soapi/service"
"github.com/gin-gonic/gin"
)
//Search 自营搜索
func
Search
(
c
*
gin
.
Context
)
{
appG
:=
app
.
Gin
{
C
:
c
}
//先去处理请求参数
params
:=
se
lf_service
.
GetSearchParams
(
c
)
fmt
.
Println
(
params
)
params
:=
se
rvice
.
Search
(
map
[
string
]
string
{}
)
//
fmt.Println(params)
appG
.
Response
(
500
,
"错误测试"
,
params
)
appG
.
Response
(
500
,
"错误测试"
,
params
)
//appG.ResponseOk()
}
\ No newline at end of file
}
service/self
_service/self
.go
→
service/self.go
View file @
902c9278
package
se
lf_se
rvice
package
service
import
(
"fmt"
"github.com/gin-gonic/gin"
"github.com/syyongx/php2go"
)
type
Params
struct
{
GoodsName
string
`form:"goods_name/condition"`
}
func
Search
(
data
map
[
string
]
string
)
interface
{}{
params
:=
getSearchParams
(
data
)
fmt
.
Println
(
params
)
return
nil
}
func
GetSearchParams
(
c
*
gin
.
Context
)
(
params
Params
)
{
if
c
.
ShouldBindQuery
(
&
params
)
==
nil
{
//商品名称的数组
fmt
.
Println
(
params
.
GoodsName
)
}
func
getSearchParams
(
data
map
[
string
]
string
)
(
params
Params
)
{
return
params
}
...
...
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