fusenapi/product/internal/handler/getproductlisthandler.go

35 lines
835 B
Go
Raw Normal View History

2023-06-01 07:32:28 +00:00
package handler
import (
2023-06-01 10:34:41 +00:00
"fusenapi/utils/auth"
2023-06-01 07:32:28 +00:00
"net/http"
"fusenapi/product/internal/logic"
"fusenapi/product/internal/svc"
"fusenapi/product/internal/types"
"github.com/zeromicro/go-zero/rest/httpx"
)
func GetProductListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
2023-06-01 10:34:41 +00:00
//检测登录权限
userInfo, err := auth.CheckAuth(r)
if err != nil {
httpx.ErrorCtx(r.Context(), w, err)
return
}
2023-06-01 07:32:28 +00:00
var req types.GetProductListReq
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
return
}
l := logic.NewGetProductListLogic(r.Context(), svcCtx)
2023-06-01 10:34:41 +00:00
resp, err := l.GetProductList(&req, userInfo.UserId)
2023-06-01 07:32:28 +00:00
if err != nil {
httpx.ErrorCtx(r.Context(), w, err)
} else {
httpx.OkJsonCtx(r.Context(), w, resp)
}
}
}