From 20acdf9648c20c4b1e0b03af98bd0010bab66f7b Mon Sep 17 00:00:00 2001
From: wangpengfei <274878379@qq.com>
Date: 星期二, 05 九月 2023 10:31:50 +0800
Subject: [PATCH] fix

---
 api/v1/test/product.go |   31 ++++++++++++++++---------------
 1 files changed, 16 insertions(+), 15 deletions(-)

diff --git a/api/v1/test/product.go b/api/v1/test/product.go
index da50427..0cab86a 100644
--- a/api/v1/test/product.go
+++ b/api/v1/test/product.go
@@ -26,17 +26,17 @@
 // @Security ApiKeyAuth
 // @accept application/json
 // @Produce application/json
-// @Param data body test.Product true "鍒涘缓Product"
+// @Param data body request.ProductCreate true "鍒涘缓Product"
 // @Success 200 {string} string "{"success":true,"data":{},"msg":"鑾峰彇鎴愬姛"}"
 // @Router /p/createProduct [post]
 func (pApi *ProductApi) CreateProduct(c *gin.Context) {
-	var p test.Product
+	var p testReq.ProductCreate
 	err := c.ShouldBindJSON(&p)
 	if err != nil {
 		response.FailWithMessage(err.Error(), c)
 		return
 	}
-	if err := pService.CreateProduct(&p); err != nil {
+	if err := pService.CreateProduct(p.List); err != nil {
 		global.GVA_LOG.Error("鍒涘缓澶辫触!", zap.Error(err))
 		response.FailWithMessage("鍒涘缓澶辫触", c)
 	} else {
@@ -219,24 +219,25 @@
 		productList[k].Number = v.Number
 		productList[k].Name = v.Name
 		productList[k].Unit = v.Unit
-		productList[k].PurchasePrice = &v.SalePrice
-		//productList[k].MinimumStock = &v.SalePrice
-		//productList[k].MaximumStock = &v.SalePrice
-		//productList[k].Remark = &v.SalePrice
+		productList[k].PurchasePrice = v.SalePrice
+		min := int(v.MinInventory)
+		productList[k].MinimumStock = min
+		max := int(v.MaxInventory)
+		productList[k].MaximumStock = max
+		productList[k].Remark = v.Node
 		productList[k].ProductType = v.MaterialMode
 	}
 
 	if err != nil || getProductListResponse.Code != 0 {
 		global.GVA_LOG.Error("鑾峰彇澶辫触!", zap.Error(err))
 		response.FailWithMessage("鑾峰彇澶辫触", c)
-		return
+	} else {
+		response.OkWithDetailed(response.PageResult{
+			List:     productList,
+			Total:    int64(len(productList)),
+			Page:     pageInfo.Page,
+			PageSize: pageInfo.PageSize,
+		}, "鑾峰彇鎴愬姛", c)
 	}
-
-	response.OkWithDetailed(response.PageResult{
-		List:     productList,
-		Total:    int64(len(productList)),
-		Page:     pageInfo.Page,
-		PageSize: pageInfo.PageSize,
-	}, "鑾峰彇鎴愬姛", c)
 
 }

--
Gitblit v1.8.0