整合目前新的详情接口

This commit is contained in:
laodaming
2023-10-17 15:33:46 +08:00
parent 77caf2e631
commit ea1335607a
11 changed files with 568 additions and 64 deletions

View File

@@ -0,0 +1,35 @@
package handler
import (
"net/http"
"reflect"
"fusenapi/utils/basic"
"fusenapi/server/product/internal/logic"
"fusenapi/server/product/internal/svc"
"fusenapi/server/product/internal/types"
)
func GetProductDetailHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.GetProductDetailReq
userinfo, err := basic.RequestParse(w, r, svcCtx, &req)
if err != nil {
return
}
// 创建一个业务逻辑层实例
l := logic.NewGetProductDetailLogic(r.Context(), svcCtx)
rl := reflect.ValueOf(l)
basic.BeforeLogic(w, r, rl)
resp := l.GetProductDetail(&req, userinfo)
if !basic.AfterLogic(w, r, rl, resp) {
basic.NormalAfterLogic(w, r, resp)
}
}
}

View File

@@ -72,6 +72,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
Path: "/api/product/home_page_recommend",
Handler: HomePageRecommendProductListHandler(serverCtx),
},
{
Method: http.MethodGet,
Path: "/api/product/get_product_detail",
Handler: GetProductDetailHandler(serverCtx),
},
},
)
}