This commit is contained in:
Mrx
2026-05-16 15:45:05 +08:00
parent 867a1022dd
commit a81f5198e3
14 changed files with 8683 additions and 2 deletions

View File

@@ -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{
{

View 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)
}
}

View 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)
}
}