From c1145113aa49b71117cd61c638c42dc0c75e8c7e Mon Sep 17 00:00:00 2001 From: admin Date: Wed, 10 Jun 2026 21:51:34 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=95=86=E5=93=81?= =?UTF-8?q?=E5=85=8B=E9=87=8D=E4=BF=9D=E5=AD=98=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - schema添加Weight字段 - Create和Update处理中添加Weight字段支持 Co-Authored-By: Claude Fable 5 --- backend/internal/api/handlers/product.go | 4 ++++ backend/internal/schemas/product.go | 2 ++ 2 files changed, 6 insertions(+) diff --git a/backend/internal/api/handlers/product.go b/backend/internal/api/handlers/product.go index 513e72a..8fe6338 100644 --- a/backend/internal/api/handlers/product.go +++ b/backend/internal/api/handlers/product.go @@ -236,6 +236,7 @@ func (h *ProductHandler) Create(c *gin.Context) { Name: req.Name, Description: req.Description, Price: req.Price, + Weight: req.Weight, MinPurchase: req.MinPurchase, MaxPurchase: req.MaxPurchase, MinWeight: req.MinWeight, @@ -299,6 +300,9 @@ func (h *ProductHandler) Update(c *gin.Context) { if req.Price != nil { updates["price"] = *req.Price } + if req.Weight != nil { + updates["weight"] = *req.Weight + } if req.MinPurchase != nil { updates["min_purchase"] = *req.MinPurchase } diff --git a/backend/internal/schemas/product.go b/backend/internal/schemas/product.go index 1a3b2b2..9cfd4e0 100644 --- a/backend/internal/schemas/product.go +++ b/backend/internal/schemas/product.go @@ -30,6 +30,7 @@ type CreateProductRequest struct { Name string `json:"name" binding:"required"` Description string `json:"description"` Price float64 `json:"price" binding:"gte=0"` + Weight float64 `json:"weight"` MinPurchase int `json:"min_purchase"` MaxPurchase *int `json:"max_purchase"` MinWeight *float64 `json:"min_weight"` @@ -49,6 +50,7 @@ type UpdateProductRequest struct { Name *string `json:"name"` Description *string `json:"description"` Price *float64 `json:"price"` + Weight *float64 `json:"weight"` MinPurchase *int `json:"min_purchase"` MaxPurchase *int `json:"max_purchase"` MinWeight *float64 `json:"min_weight"`