From c950586b718ae6fc198bedf424609a4ac94cb5d1 Mon Sep 17 00:00:00 2001 From: zhangqian <zhangqian@123.com> Date: 星期四, 04 七月 2024 18:16:07 +0800 Subject: [PATCH] 增加根据位置或仓库查询产品及库存列表 --- controllers/location_product_amount.go | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 46 insertions(+), 0 deletions(-) diff --git a/controllers/location_product_amount.go b/controllers/location_product_amount.go index 87ff91b..02d4bad 100644 --- a/controllers/location_product_amount.go +++ b/controllers/location_product_amount.go @@ -143,6 +143,52 @@ util.ResponseFormatListWithPage(c, code.Success, records, int(total), params.Page, params.PageSize) } +// LocationProductList +// @Tags 搴撳瓨鐩樼偣 +// @Summary 鑾峰彇浣嶇疆瀵瑰簲浜у搧鍒楄〃 +// @Produce application/json +// @Param object body request.GetLocationProductList true "鏌ヨ鍙傛暟" +// @Param Authorization header string true "token" +// @Success 200 {object} util.Response "鎴愬姛" +// @Router /api-wms/v1/locationProductAmount/locationProductList [post] +func (slf LocationProductAmountController) LocationProductList(c *gin.Context) { + var params request.GetLocationProductList + if err := c.BindJSON(¶ms); err != nil { + util.ResponseFormat(c, code.RequestParamError, "鍙傛暟瑙f瀽澶辫触锛屾暟鎹被鍨嬮敊璇�:"+err.Error()) + return + } + if !params.Check() { + util.ResponseFormat(c, code.RequestParamError, "鍙傛暟寮傚父") + return + } + productIds := make([]string, 0) + locationIds := make([]int, 0) + if params.Keyword != "" { + materials, _ := models.NewMaterialSearch().SetKeyword(params.Keyword).FindNotTotal() + for _, material := range materials { + productIds = append(productIds, material.ID) + } + locations, _ := models.NewLocationSearch().SetKeyword(params.Keyword).FindNotTotal() + for _, location := range locations { + locationIds = append(locationIds, location.Id) + } + } + + search := models.NewLocationProductAmountSearch() + records, total, err := search. + SetLocationIds(locationIds).SetWarehouseId(params.WarehouseId).SetProductIds(productIds).SetLocationId(params.LocationId). + SetPage(params.Page, params.PageSize). + SetOrder("id desc"). + SetPreload(true). + FindByPage() + if err != nil { + util.ResponseFormat(c, code.InternalError, "鏌ヨ澶辫触") + return + } + + util.ResponseFormatList(c, code.Success, records, int(total)) +} + // Add // @Tags 搴撳瓨鐩樼偣 // @Summary 娣诲姞搴撳瓨鐩樼偣淇℃伅 -- Gitblit v1.8.0