tyc-server/app/main/api/internal/handler/product/getproductbyidhandler.go

31 lines
795 B
Go
Raw Normal View History

2024-11-21 12:18:28 +08:00
package product
import (
"net/http"
2025-04-27 12:17:18 +08:00
"tyc-server/app/main/api/internal/logic/product"
"tyc-server/app/main/api/internal/svc"
"tyc-server/app/main/api/internal/types"
2025-04-09 15:58:06 +08:00
"tyc-server/common/result"
"tyc-server/pkg/lzkit/validator"
2024-11-21 12:18:28 +08:00
"github.com/zeromicro/go-zero/rest/httpx"
)
func GetProductByIDHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.GetProductByIDRequest
if err := httpx.Parse(r, &req); err != nil {
result.ParamErrorResult(r, w, err)
return
}
if err := validator.Validate(req); err != nil {
result.ParamValidateErrorResult(r, w, err)
return
}
l := product.NewGetProductByIDLogic(r.Context(), svcCtx)
resp, err := l.GetProductByID(&req)
result.HttpResult(r, w, resp, err)
}
}