新增APP查询页

This commit is contained in:
2025-03-14 02:56:27 +08:00
parent ece4b5d1b1
commit 0e6cb95499
11 changed files with 209 additions and 33 deletions

View File

@@ -0,0 +1,29 @@
package product
import (
"net/http"
"github.com/zeromicro/go-zero/rest/httpx"
"tydata-server/app/user/cmd/api/internal/logic/product"
"tydata-server/app/user/cmd/api/internal/svc"
"tydata-server/app/user/cmd/api/internal/types"
"tydata-server/common/result"
"tydata-server/pkg/lzkit/validator"
)
func GetProductAppByEnHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.GetProductByEnRequest
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 := product.NewGetProductAppByEnLogic(r.Context(), svcCtx)
resp, err := l.GetProductAppByEn(&req)
result.HttpResult(r, w, resp, err)
}
}

View File

@@ -0,0 +1,29 @@
package query
import (
"net/http"
"github.com/zeromicro/go-zero/rest/httpx"
"tydata-server/app/user/cmd/api/internal/logic/query"
"tydata-server/app/user/cmd/api/internal/svc"
"tydata-server/app/user/cmd/api/internal/types"
"tydata-server/common/result"
"tydata-server/pkg/lzkit/validator"
)
func QueryServiceAppHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.QueryServiceReq
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 := query.NewQueryServiceLogic(r.Context(), svcCtx)
resp, err := l.QueryService(&req)
result.HttpResult(r, w, resp, err)
}
}

View File

@@ -182,6 +182,17 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
rest.WithPrefix("/api/v1/product"),
)
server.AddRoutes(
[]rest.Route{
{
Method: http.MethodGet,
Path: "/app_en/:product_en",
Handler: product.GetProductAppByEnHandler(serverCtx),
},
},
rest.WithPrefix("/api/v1/product"),
)
server.AddRoutes(
[]rest.Route{
{
@@ -190,6 +201,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
Path: "/query/service_agent/:product",
Handler: query.QueryServiceAgentHandler(serverCtx),
},
{
Method: http.MethodPost,
Path: "/query/service_app/:product",
Handler: query.QueryServiceAppHandler(serverCtx),
},
},
rest.WithPrefix("/api/v1"),
)