Commit 902c9278 by 杨树贤

整理代码

parent 0c95ad35
......@@ -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
......
......@@ -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=
......
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("/search", controller.Search)
apiSelf.GET("/self/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
......
package hrpc
type SelfServer struct {
}
func (s *SelfServer) Search() {
}
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 := self_service.GetSearchParams(c)
fmt.Println(params)
params := service.Search(map[string]string{})
//fmt.Println(params)
appG.Response(500,"错误测试",params)
appG.Response(500, "错误测试", params)
//appG.ResponseOk()
}
\ No newline at end of file
}
package self_service
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
}
......
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