fusenapi/product/internal/handler/getproductlisthandler.go
laodaming 19f988eccd fix
2023-06-05 12:21:15 +08:00

32 lines
864 B
Go

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 GetProductListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
//检测登录权限
userInfo := auth.CheckAuth(r)
var req types.GetProductListReq
if err := httpx.Parse(r, &req); err != nil {
httpx.OkJsonCtx(r.Context(), w, types.Response{Code: 500, Message: err.Error()})
return
}
l := logic.NewGetProductListLogic(r.Context(), svcCtx)
resp, err := l.GetProductList(&req, userInfo)
if err != nil {
httpx.OkJsonCtx(r.Context(), w, types.Response{Code: 500, Message: err.Error()})
} else {
httpx.OkJsonCtx(r.Context(), w, resp)
}
}
}