From b9a62531fb93aba42d13e62fd1b03d8dba112fa6 Mon Sep 17 00:00:00 2001 From: liujiandao <274878379@qq.com> Date: 星期一, 23 十月 2023 12:04:31 +0800 Subject: [PATCH] 位置修改 --- models/location_product_amount.go | 51 ++++++++++++++++++++++++++++++++++++--------------- 1 files changed, 36 insertions(+), 15 deletions(-) diff --git a/models/location_product_amount.go b/models/location_product_amount.go index c2ee64c..b51e00c 100644 --- a/models/location_product_amount.go +++ b/models/location_product_amount.go @@ -4,6 +4,7 @@ "fmt" "github.com/shopspring/decimal" "gorm.io/gorm" + "wms/constvar" "wms/pkg/mysqlx" ) @@ -19,25 +20,29 @@ LocationProductAmountSearch struct { LocationProductAmount - Order string - PageNum int - PageSize int - Keyword string - Orm *gorm.DB - Preload bool + Order string + PageNum int + PageSize int + Keyword string + Orm *gorm.DB + Preload bool + LocationProductIds []int } LocationProductAmountWithOperation struct { //LocationProductAmount LocationProductAmount `json:"locationProductAmount"` - LocationId int `json:"locationId" gorm:"column:location_id"` - LocationName string `json:"locationName" gorm:"column:location_name"` - ProductId string `json:"productId" gorm:"column:product_id"` - ProductName string `json:"productName" gorm:"column:product_name"` - Amount decimal.Decimal `json:"amount" gorm:"column:amount"` - Unit string `json:"unit" gorm:"column:unit"` - CreateDate string `json:"createDate" gorm:"column:create_date"` - AdjustAmount decimal.Decimal `json:"adjustAmount" gorm:"column:adjust_amount"` - DifferenceAmount decimal.Decimal `json:"differenceAmount" gorm:"-"` + LocationProductAmountId int `json:"locationProductAmountId" gorm:"location_product_amount_id"` + LocationId int `json:"locationId" gorm:"column:location_id"` + LocationName string `json:"locationName" gorm:"column:location_name"` + ProductId string `json:"productId" gorm:"column:product_id"` + ProductName string `json:"productName" gorm:"column:product_name"` + Amount decimal.Decimal `json:"amount" gorm:"column:amount"` + Unit string `json:"unit" gorm:"column:unit"` + CreateDate string `json:"createDate" gorm:"column:create_date"` + AdjustAmount decimal.Decimal `json:"adjustAmount" gorm:"column:adjust_amount"` + DifferenceAmount decimal.Decimal `json:"differenceAmount" gorm:"-"` + OperationId int `json:"operationId" gorm:"column:operation_id"` + Status constvar.OperationStatus `json:"status" gorm:"status"` } ) @@ -79,6 +84,16 @@ return slf } +func (slf *LocationProductAmountSearch) SetLocationProductId(id int) *LocationProductAmountSearch { + slf.LocationProductId = id + return slf +} + +func (slf *LocationProductAmountSearch) SetLocationProductIds(ids []int) *LocationProductAmountSearch { + slf.LocationProductIds = ids + return slf +} + func (slf *LocationProductAmountSearch) build() *gorm.DB { var db = slf.Orm.Model(&LocationProductAmount{}) @@ -96,6 +111,12 @@ if slf.Preload { db = db.Model(&LocationProductAmount{}).Preload("LocationProduct").Preload("LocationProduct.Location").Preload("LocationProduct.Product") } + if slf.LocationProductId != 0 { + db = db.Where("location_product_id=?", slf.LocationProductId) + } + if len(slf.LocationProductIds) > 0 { + db = db.Where("location_product_id in (?)", slf.LocationProductIds) + } return db } -- Gitblit v1.8.0