f
This commit is contained in:
@@ -28,6 +28,7 @@ import (
|
||||
product "tyc-server/app/main/api/internal/handler/product"
|
||||
query "tyc-server/app/main/api/internal/handler/query"
|
||||
tianyuan "tyc-server/app/main/api/internal/handler/tianyuan"
|
||||
toolbox "tyc-server/app/main/api/internal/handler/toolbox"
|
||||
upload "tyc-server/app/main/api/internal/handler/upload"
|
||||
user "tyc-server/app/main/api/internal/handler/user"
|
||||
"tyc-server/app/main/api/internal/svc"
|
||||
@@ -1175,6 +1176,24 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
|
||||
rest.WithPrefix("/api/v1"),
|
||||
)
|
||||
|
||||
server.AddRoutes(
|
||||
[]rest.Route{
|
||||
{
|
||||
// 获取工具列表
|
||||
Method: http.MethodGet,
|
||||
Path: "/toolbox/list",
|
||||
Handler: toolbox.ToolboxListHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
// 通用工具查询
|
||||
Method: http.MethodPost,
|
||||
Path: "/toolbox/query",
|
||||
Handler: toolbox.ToolboxQueryHandler(serverCtx),
|
||||
},
|
||||
},
|
||||
rest.WithPrefix("/api/v1"),
|
||||
)
|
||||
|
||||
server.AddRoutes(
|
||||
[]rest.Route{
|
||||
{
|
||||
|
||||
17
app/main/api/internal/handler/toolbox/toolboxlisthandler.go
Normal file
17
app/main/api/internal/handler/toolbox/toolboxlisthandler.go
Normal file
@@ -0,0 +1,17 @@
|
||||
package toolbox
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"tyc-server/app/main/api/internal/logic/toolbox"
|
||||
"tyc-server/app/main/api/internal/svc"
|
||||
"tyc-server/common/result"
|
||||
)
|
||||
|
||||
func ToolboxListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
l := toolbox.NewToolboxListLogic(r.Context(), svcCtx)
|
||||
resp, err := l.ToolboxList()
|
||||
result.HttpResult(r, w, resp, err)
|
||||
}
|
||||
}
|
||||
29
app/main/api/internal/handler/toolbox/toolboxqueryhandler.go
Normal file
29
app/main/api/internal/handler/toolbox/toolboxqueryhandler.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package toolbox
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"tyc-server/app/main/api/internal/logic/toolbox"
|
||||
"tyc-server/app/main/api/internal/svc"
|
||||
"tyc-server/app/main/api/internal/types"
|
||||
"tyc-server/common/result"
|
||||
"tyc-server/pkg/lzkit/validator"
|
||||
)
|
||||
|
||||
func ToolboxQueryHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.ToolboxQueryReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
result.ParamErrorResult(r, w, err)
|
||||
return
|
||||
}
|
||||
if err := validator.Validate(req); err != nil {
|
||||
result.ParamValidateErrorResult(r, w, err)
|
||||
return
|
||||
}
|
||||
l := toolbox.NewToolboxQueryLogic(r.Context(), svcCtx)
|
||||
resp, err := l.ToolboxQuery(&req)
|
||||
result.HttpResult(r, w, resp, err)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user