From c2be95e83d1597eed8623fdd70a77d617465f91e Mon Sep 17 00:00:00 2001 From: zhangqian <zhangqian@123.com> Date: 星期五, 29 三月 2024 17:04:31 +0800 Subject: [PATCH] 查操作明细增加查询字段 --- models/operation_details.go | 29 +++++++++++++++++++++++------ 1 files changed, 23 insertions(+), 6 deletions(-) diff --git a/models/operation_details.go b/models/operation_details.go index 18e8cfd..0434ac9 100644 --- a/models/operation_details.go +++ b/models/operation_details.go @@ -11,12 +11,18 @@ // 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:浜у搧鍚嶇О"` //浜у搧鍚嶇О - Amount decimal.Decimal `json:"amount" 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"` + + FromLocationID int `json:"fromLocationId" gorm:"type:int;not null;comment:婧愪綅缃甶d"` //婧愪綅缃甶d + FromLocation Location `json:"fromLocation" gorm:"foreignKey:FromLocationID;references:Id"` //婧愪綅缃� + ToLocationID int `json:"toLocationId" gorm:"type:int;not null;comment:鐩爣浣嶇疆id"` //鐩爣浣嶇疆id + ToLocation Location `json:"toLocation" gorm:"foreignKey:ToLocationID;references:Id"` //鐩爣浣嶇疆 } OperationDetailsSearch struct { @@ -73,6 +79,11 @@ 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{}) @@ -91,6 +102,12 @@ if slf.OperationID != 0 { db = db.Where("operation_id = ?", slf.OperationID) } + if slf.ProductId != "" { + db = db.Where("product_id = ?", slf.ProductId) + } + if slf.Preload { + db = db.Preload("Product") + } return db } -- Gitblit v1.8.0