From 5200927fcd5a352c540d42f9ecba0845367d1938 Mon Sep 17 00:00:00 2001
From: zhangqian <zhangqian@123.com>
Date: 星期四, 04 七月 2024 20:02:49 +0800
Subject: [PATCH] 产品库存列表返回结构调整

---
 controllers/location_product_amount.go |   18 ++++++++++++++++--
 1 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/controllers/location_product_amount.go b/controllers/location_product_amount.go
index 7754e46..abd668c 100644
--- a/controllers/location_product_amount.go
+++ b/controllers/location_product_amount.go
@@ -4,6 +4,7 @@
 	"errors"
 	"fmt"
 	"github.com/gin-gonic/gin"
+	"github.com/mitchellh/mapstructure"
 	"github.com/shopspring/decimal"
 	"gorm.io/gorm"
 	"strconv"
@@ -149,7 +150,7 @@
 // @Produce   application/json
 // @Param		 object  body  request.GetLocationProductList true  "鏌ヨ鍙傛暟"
 // @Param     Authorization	header string true "token"
-// @Success   200 {object} util.Response	"鎴愬姛"
+// @Success   200 {object} util.ResponseList(data=[]*response.LocationProductAmount)	"鎴愬姛"
 // @Router    /api-wms/v1/locationProductAmount/locationProductList [post]
 func (slf LocationProductAmountController) LocationProductList(c *gin.Context) {
 	var params request.GetLocationProductList
@@ -186,7 +187,20 @@
 		return
 	}
 
-	util.ResponseFormatList(c, code.Success, records, int(total))
+	dataList := make([]*response.LocationProductAmount, 0, len(records))
+
+	for _, v := range records {
+		data := new(response.LocationProductAmount)
+		mapstructure.Decode(v.Product, &data)
+		data.ID = v.ProductId
+		data.LocationId = v.LocationId
+		data.Location = v.Location
+		data.Amount = v.Amount
+		data.ProductId = v.ProductId
+		dataList = append(dataList, data)
+	}
+
+	util.ResponseFormatList(c, code.Success, dataList, int(total))
 }
 
 // Add

--
Gitblit v1.8.0