fusenapi/product/internal/handler/getproductlisthandler.go

31 lines
752 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
//检测登录权限
2023-06-02 04:12:51 +00:00
userInfo := auth.CheckAuth(r)
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-02 04:12:51 +00:00
resp, err := l.GetProductList(&req, userInfo)
2023-06-01 07:32:28 +00:00
if err != nil {
httpx.ErrorCtx(r.Context(), w, err)
} else {
httpx.OkJsonCtx(r.Context(), w, resp)
}
}
}