fix: 修复商品克重保存问题
- schema添加Weight字段 - Create和Update处理中添加Weight字段支持 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -236,6 +236,7 @@ func (h *ProductHandler) Create(c *gin.Context) {
|
|||||||
Name: req.Name,
|
Name: req.Name,
|
||||||
Description: req.Description,
|
Description: req.Description,
|
||||||
Price: req.Price,
|
Price: req.Price,
|
||||||
|
Weight: req.Weight,
|
||||||
MinPurchase: req.MinPurchase,
|
MinPurchase: req.MinPurchase,
|
||||||
MaxPurchase: req.MaxPurchase,
|
MaxPurchase: req.MaxPurchase,
|
||||||
MinWeight: req.MinWeight,
|
MinWeight: req.MinWeight,
|
||||||
@@ -299,6 +300,9 @@ func (h *ProductHandler) Update(c *gin.Context) {
|
|||||||
if req.Price != nil {
|
if req.Price != nil {
|
||||||
updates["price"] = *req.Price
|
updates["price"] = *req.Price
|
||||||
}
|
}
|
||||||
|
if req.Weight != nil {
|
||||||
|
updates["weight"] = *req.Weight
|
||||||
|
}
|
||||||
if req.MinPurchase != nil {
|
if req.MinPurchase != nil {
|
||||||
updates["min_purchase"] = *req.MinPurchase
|
updates["min_purchase"] = *req.MinPurchase
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ type CreateProductRequest struct {
|
|||||||
Name string `json:"name" binding:"required"`
|
Name string `json:"name" binding:"required"`
|
||||||
Description string `json:"description"`
|
Description string `json:"description"`
|
||||||
Price float64 `json:"price" binding:"gte=0"`
|
Price float64 `json:"price" binding:"gte=0"`
|
||||||
|
Weight float64 `json:"weight"`
|
||||||
MinPurchase int `json:"min_purchase"`
|
MinPurchase int `json:"min_purchase"`
|
||||||
MaxPurchase *int `json:"max_purchase"`
|
MaxPurchase *int `json:"max_purchase"`
|
||||||
MinWeight *float64 `json:"min_weight"`
|
MinWeight *float64 `json:"min_weight"`
|
||||||
@@ -49,6 +50,7 @@ type UpdateProductRequest struct {
|
|||||||
Name *string `json:"name"`
|
Name *string `json:"name"`
|
||||||
Description *string `json:"description"`
|
Description *string `json:"description"`
|
||||||
Price *float64 `json:"price"`
|
Price *float64 `json:"price"`
|
||||||
|
Weight *float64 `json:"weight"`
|
||||||
MinPurchase *int `json:"min_purchase"`
|
MinPurchase *int `json:"min_purchase"`
|
||||||
MaxPurchase *int `json:"max_purchase"`
|
MaxPurchase *int `json:"max_purchase"`
|
||||||
MinWeight *float64 `json:"min_weight"`
|
MinWeight *float64 `json:"min_weight"`
|
||||||
|
|||||||
Reference in New Issue
Block a user