From c2be95e83d1597eed8623fdd70a77d617465f91e Mon Sep 17 00:00:00 2001 From: zhangqian <zhangqian@123.com> Date: 星期五, 29 三月 2024 17:04:31 +0800 Subject: [PATCH] 查操作明细增加查询字段 --- models/warehouse.go | 13 ++++++++++++- 1 files changed, 12 insertions(+), 1 deletions(-) diff --git a/models/warehouse.go b/models/warehouse.go index ebdf7b3..0b1c74f 100644 --- a/models/warehouse.go +++ b/models/warehouse.go @@ -25,7 +25,7 @@ Address string `json:"address" gorm:"type:varchar(512);comment:鍦板潃"` //鍦板潃 InboundTransportation int `json:"inboundTransportation" gorm:"type:int;comment:鍏ュ悜杩愯緭"` //鍏ュ悜杩愯緭 OutboundTransportation int `json:"outboundTransportation" gorm:"type:int;comment:鍑哄簱杩愯緭"` //鍑哄簱杩愯緭 - LocationId int `json:"locationId" gorm:"type:int;comment:浣嶇疆id"` //浣嶇疆id + LocationId int `json:"locationId" gorm:"type:int;comment:浣嶇疆id"` //榛樿浣嶇疆id WarehouseLocation string `json:"warehouseLocation" gorm:"-"` //搴撳瓨浣嶇疆 Contacts string `json:"contacts" gorm:"type:varchar(255);comment:鑱旂郴浜�"` //鑱旂郴浜� } @@ -38,6 +38,7 @@ Keyword string Orm *gorm.DB Preload bool + Codes []string } ) @@ -79,6 +80,11 @@ return slf } +func (slf *WarehouseSearch) SetCodes(codes []string) *WarehouseSearch { + slf.Codes = codes + return slf +} + func (slf *WarehouseSearch) SetName(name string) *WarehouseSearch { slf.Name = name return slf @@ -116,10 +122,15 @@ if slf.Preload { db = db.Preload("Company") } + if slf.Code != "" { db = db.Where("code = ?", slf.Code) } + if len(slf.Codes) > 0 { + db = db.Where("code in ?", slf.Codes) + } + return db } -- Gitblit v1.8.0