| | |
| | | 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, "参数解析失败,数据类型错误:"+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 添加库存盘点信息 |