fusenapi/server/canteen/internal/handler/getcanteendetailhandler.go
laodaming 2a18f0c21a fix
2023-06-09 12:07:54 +08:00

39 lines
939 B
Go

package handler
import (
"errors"
"net/http"
"github.com/zeromicro/go-zero/core/logx"
"github.com/zeromicro/go-zero/rest/httpx"
"fusenapi/server/canteen/internal/logic"
"fusenapi/server/canteen/internal/svc"
"fusenapi/server/canteen/internal/types"
)
// 获取餐厅详情
func GetCanteenDetailHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.GetCanteenDetailReq
if err := httpx.Parse(r, &req); err != nil {
httpx.OkJsonCtx(r.Context(), w, &types.Response{
Code: 510,
Message: "parameter error",
})
logx.Info(err)
return
}
l := logic.NewGetCanteenDetailLogic(r.Context(), svcCtx)
resp := l.GetCanteenDetail(&req)
if resp != nil {
httpx.OkJsonCtx(r.Context(), w, resp)
} else {
err := errors.New("server logic is error, resp must not be nil")
httpx.ErrorCtx(r.Context(), w, err)
logx.Error(err)
}
}
}