新增产品详情api
This commit is contained in:
31
product/internal/handler/getproductinfohandler.go
Normal file
31
product/internal/handler/getproductinfohandler.go
Normal file
@@ -0,0 +1,31 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"fusenapi/utils/auth"
|
||||
"net/http"
|
||||
|
||||
"fusenapi/product/internal/logic"
|
||||
"fusenapi/product/internal/svc"
|
||||
"fusenapi/product/internal/types"
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
)
|
||||
|
||||
func GetProductInfoHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
//检测登录权限
|
||||
userInfo := auth.CheckAuth(r)
|
||||
var req types.GetProductInfoReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
httpx.ErrorCtx(r.Context(), w, err)
|
||||
return
|
||||
}
|
||||
|
||||
l := logic.NewGetProductInfoLogic(r.Context(), svcCtx)
|
||||
resp, err := l.GetProductInfo(&req, userInfo)
|
||||
if err != nil {
|
||||
httpx.ErrorCtx(r.Context(), w, err)
|
||||
} else {
|
||||
httpx.OkJsonCtx(r.Context(), w, resp)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -17,6 +17,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
|
||||
Path: "/product/list",
|
||||
Handler: GetProductListHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
Method: http.MethodGet,
|
||||
Path: "/product/info",
|
||||
Handler: GetProductInfoHandler(serverCtx),
|
||||
},
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user