From 96844c22ef3fba86a55e0af1b51bc1009d6fa950 Mon Sep 17 00:00:00 2001 From: jiangshuai <291802688@qq.com> Date: 星期五, 20 十月 2023 11:57:48 +0800 Subject: [PATCH] 1.库存盘点bug修改 --- models/operation_details.go | 36 ++++++++++++++++++++++-------------- 1 files changed, 22 insertions(+), 14 deletions(-) diff --git a/models/operation_details.go b/models/operation_details.go index 270e34d..9e89e77 100644 --- a/models/operation_details.go +++ b/models/operation_details.go @@ -11,13 +11,13 @@ // OperationDetails 鎿嶄綔鏄庣粏琛� OperationDetails struct { WmsModel - - Id int `json:"id" gorm:"column:id;primary_key;AUTO_INCREMENT"` - OperationId int `json:"OperationId" gorm:"type:int;not null;comment:鎿嶄綔璁板綍id"` //鎿嶄綔id - ProductId string `json:"productId" gorm:"type:varchar(191);not null;comment:浜у搧id"` //浜у搧id - ProductName string `json:"productName" gorm:"type:varchar(255);not null;comment:浜у搧鍚嶇О"` //浜у搧鍚嶇О - Quantity decimal.Decimal `json:"quantity" gorm:"type:decimal(20,2);not null;comment:鏁伴噺"` //鏁伴噺 - Unit string `json:"unit" gorm:"type:varchar(31);comment:鍗曚綅"` + Id int `json:"id" gorm:"column:id;primary_key;AUTO_INCREMENT"` + OperationID int `json:"operationId" gorm:"type:int;not null;comment:鎿嶄綔璁板綍id"` //鎿嶄綔id + ProductId string `json:"productId" gorm:"type:varchar(191);not null;comment:浜у搧id"` //浜у搧id + //ProductName string `json:"productName" gorm:"type:varchar(255);not null;comment:浜у搧鍚嶇О"` //浜у搧鍚嶇О + Amount decimal.Decimal `json:"amount" gorm:"type:decimal(20,2);not null;comment:鏁伴噺"` //鏁伴噺 + //Unit string `json:"unit" gorm:"type:varchar(31);comment:鍗曚綅"` //鍗曚綅 + Product Material `json:"product" gorm:"foreignKey:ProductId;references:ID"` } OperationDetailsSearch struct { @@ -54,8 +54,8 @@ return slf } -func (slf *OperationDetailsSearch) SetID(id uint) *OperationDetailsSearch { - slf.ID = id +func (slf *OperationDetailsSearch) SetID(ID int) *OperationDetailsSearch { + slf.Id = ID return slf } @@ -70,15 +70,20 @@ } func (slf *OperationDetailsSearch) SetOperationId(operationId int) *OperationDetailsSearch { - slf.OperationId = operationId + slf.OperationID = operationId + return slf +} + +func (slf *OperationDetailsSearch) SetProductId(productId string) *OperationDetailsSearch { + slf.ProductId = productId return slf } func (slf *OperationDetailsSearch) build() *gorm.DB { var db = slf.Orm.Model(&OperationDetails{}) - if slf.ID != 0 { - db = db.Where("id = ?", slf.ID) + if slf.Id != 0 { + db = db.Where("id = ?", slf.Id) } if slf.Order != "" { @@ -89,8 +94,11 @@ db = db.Where("product_name like ?", fmt.Sprintf("%%%v%%", slf.Keyword)) } - if slf.OperationId != 0 { - db = db.Where("operation_id = ?", slf.OperationId) + if slf.OperationID != 0 { + db = db.Where("operation_id = ?", slf.OperationID) + } + if slf.ProductId != "" { + db = db.Where("product_id = ?", slf.ProductId) } return db -- Gitblit v1.8.0