From 076f911a3b8d09364d1d8c98a92b48e601ae6a21 Mon Sep 17 00:00:00 2001 From: zhangqian <zhangqian@123.com> Date: 星期三, 31 七月 2024 11:30:27 +0800 Subject: [PATCH] 位置对应产品列表增加产品类别筛选 --- controllers/location_product_amount.go | 29 ++++++++++++++++++++++++----- 1 files changed, 24 insertions(+), 5 deletions(-) diff --git a/controllers/location_product_amount.go b/controllers/location_product_amount.go index 7754e46..c717ed0 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 @@ -180,19 +181,34 @@ SetPage(params.Page, params.PageSize). SetOrder("id desc"). SetPreload(true). + SetCategoryIds(params.CategoryIds). FindByPage() if err != nil { util.ResponseFormat(c, code.InternalError, "鏌ヨ澶辫触") 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] @@ -318,6 +334,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,13 +372,15 @@ } // Finish +// deprecated // -// @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