From ccf9ccce0fefbee8428c98a008c26d8ea26b2af1 Mon Sep 17 00:00:00 2001 From: yinbentan <yinbentan@live.com> Date: 星期四, 18 七月 2024 10:26:38 +0800 Subject: [PATCH] 修改方法,修复BUG --- controllers/location_product_amount.go | 28 +++++++++++++++++++++++----- 1 files changed, 23 insertions(+), 5 deletions(-) diff --git a/controllers/location_product_amount.go b/controllers/location_product_amount.go index 02d4bad..12807dd 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,13 +187,27 @@ 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 // @Tags 搴撳瓨鐩樼偣 // @Summary 娣诲姞搴撳瓨鐩樼偣淇℃伅 // @Produce application/json +// @Param Authorization header string true "token" // @Param object body request.UpdateLocationProductAmount true "鍏ュ簱/鍑哄簱淇℃伅" // @Success 200 {object} util.Response "鎴愬姛" // @Router /api-wms/v1/locationProductAmount/add [post] @@ -248,6 +263,7 @@ ProductId: reqParams.ProductId, Amount: decimal.NewFromInt(0), CreateDate: time.Now().Format("2006-01-02 15:04:05"), + WarehouseId: location.WarehouseId, } } @@ -317,6 +333,7 @@ // @Tags 搴撳瓨鐩樼偣 // @Summary 淇敼搴撳瓨鐩樼偣淇℃伅 // @Produce application/json +// @Param Authorization header string true "token" // @Param object body request.UpdateLocationProductAmount true "鍏ュ簱/鍑哄簱淇℃伅" // @Success 200 {object} util.Response "鎴愬姛" // @Router /api-wms/v1/locationProductAmount/update [post] @@ -355,12 +372,13 @@ // Finish // -// @Tags 搴撳瓨鐩樼偣 +// @Tags 搴撳瓨鐩樼偣 // @Summary 搴旂敤銆侀獙璇� // @Produce application/json -// @Param object body request.FinishLocationProductAmount true "鍏ュ弬" +// @Param Authorization header string true "token" +// @Param object body request.FinishLocationProductAmount true "鍏ュ弬" // @Success 200 {object} util.Response "鎴愬姛" -// @Router /api-wms/v1/locationProductAmount/finish [post] +// @Router /api-wms/v1/locationProductAmount/finish [post] func (slf LocationProductAmountController) Finish(c *gin.Context) { var reqParams request.FinishLocationProductAmount if err := c.BindJSON(&reqParams); err != nil { -- Gitblit v1.8.0