init
This commit is contained in:
28
service/api/internal/handler/api/goodsdetailshandler.go
Normal file
28
service/api/internal/handler/api/goodsdetailshandler.go
Normal file
@ -0,0 +1,28 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"hk/service/api/internal/logic/api"
|
||||
"hk/service/api/internal/svc"
|
||||
"hk/service/api/internal/types"
|
||||
)
|
||||
|
||||
func GoodsDetailsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.GoodsDetailsReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
httpx.ErrorCtx(r.Context(), w, err)
|
||||
return
|
||||
}
|
||||
|
||||
l := api.NewGoodsDetailsLogic(r.Context(), svcCtx)
|
||||
resp, err := l.GoodsDetails(&req)
|
||||
if err != nil {
|
||||
httpx.ErrorCtx(r.Context(), w, err)
|
||||
} else {
|
||||
httpx.OkJsonCtx(r.Context(), w, resp)
|
||||
}
|
||||
}
|
||||
}
|
28
service/api/internal/handler/api/goodslisthandler.go
Normal file
28
service/api/internal/handler/api/goodslisthandler.go
Normal file
@ -0,0 +1,28 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"hk/service/api/internal/logic/api"
|
||||
"hk/service/api/internal/svc"
|
||||
"hk/service/api/internal/types"
|
||||
)
|
||||
|
||||
func GoodsListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.GoodsListReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
httpx.ErrorCtx(r.Context(), w, err)
|
||||
return
|
||||
}
|
||||
|
||||
l := api.NewGoodsListLogic(r.Context(), svcCtx)
|
||||
resp, err := l.GoodsList(&req)
|
||||
if err != nil {
|
||||
httpx.ErrorCtx(r.Context(), w, err)
|
||||
} else {
|
||||
httpx.OkJsonCtx(r.Context(), w, resp)
|
||||
}
|
||||
}
|
||||
}
|
28
service/api/internal/handler/api/order172handler.go
Normal file
28
service/api/internal/handler/api/order172handler.go
Normal file
@ -0,0 +1,28 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"hk/service/api/internal/logic/api"
|
||||
"hk/service/api/internal/svc"
|
||||
"hk/service/api/internal/types"
|
||||
)
|
||||
|
||||
func Order172Handler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.PushReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
httpx.ErrorCtx(r.Context(), w, err)
|
||||
return
|
||||
}
|
||||
|
||||
l := api.NewOrder172Logic(r.Context(), svcCtx)
|
||||
resp, err := l.Order172(&req)
|
||||
if err != nil {
|
||||
httpx.ErrorCtx(r.Context(), w, err)
|
||||
} else {
|
||||
httpx.OkJsonCtx(r.Context(), w, resp)
|
||||
}
|
||||
}
|
||||
}
|
28
service/api/internal/handler/api/tiktokinfohandler.go
Normal file
28
service/api/internal/handler/api/tiktokinfohandler.go
Normal file
@ -0,0 +1,28 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"hk/service/api/internal/logic/api"
|
||||
"hk/service/api/internal/svc"
|
||||
"hk/service/api/internal/types"
|
||||
)
|
||||
|
||||
func TiktokInfoHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.TiktokReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
httpx.ErrorCtx(r.Context(), w, err)
|
||||
return
|
||||
}
|
||||
|
||||
l := api.NewTiktokInfoLogic(r.Context(), svcCtx)
|
||||
resp, err := l.TiktokInfo(&req)
|
||||
if err != nil {
|
||||
httpx.ErrorCtx(r.Context(), w, err)
|
||||
} else {
|
||||
httpx.OkJsonCtx(r.Context(), w, resp)
|
||||
}
|
||||
}
|
||||
}
|
44
service/api/internal/handler/routes.go
Normal file
44
service/api/internal/handler/routes.go
Normal file
@ -0,0 +1,44 @@
|
||||
// Code generated by goctl. DO NOT EDIT.
|
||||
// goctl 1.7.6
|
||||
|
||||
package handler
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
api "hk/service/api/internal/handler/api"
|
||||
"hk/service/api/internal/svc"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest"
|
||||
)
|
||||
|
||||
func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
|
||||
server.AddRoutes(
|
||||
rest.WithMiddlewares(
|
||||
[]rest.Middleware{serverCtx.RealIPMiddleware},
|
||||
[]rest.Route{
|
||||
{
|
||||
Method: http.MethodGet,
|
||||
Path: "/goods/:id",
|
||||
Handler: api.GoodsDetailsHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
Method: http.MethodGet,
|
||||
Path: "/goods/list",
|
||||
Handler: api.GoodsListHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
Method: http.MethodPost,
|
||||
Path: "/push/order172",
|
||||
Handler: api.Order172Handler(serverCtx),
|
||||
},
|
||||
{
|
||||
Method: http.MethodPost,
|
||||
Path: "/tiktok/getVideoInfo",
|
||||
Handler: api.TiktokInfoHandler(serverCtx),
|
||||
},
|
||||
}...,
|
||||
),
|
||||
rest.WithPrefix("/api"),
|
||||
)
|
||||
}
|
Reference in New Issue
Block a user