From aeed976c2999e2cea097cdee38d8baeefe323f3d Mon Sep 17 00:00:00 2001
From: liujiandao <274878379@qq.com>
Date: 星期六, 30 三月 2024 16:15:59 +0800
Subject: [PATCH] 修改

---
 models/warehouse.go |   29 +++++++++++++++++++++++------
 1 files changed, 23 insertions(+), 6 deletions(-)

diff --git a/models/warehouse.go b/models/warehouse.go
index a8db21e..0b1c74f 100644
--- a/models/warehouse.go
+++ b/models/warehouse.go
@@ -25,6 +25,9 @@
 		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
+		WarehouseLocation      string       `json:"warehouseLocation" gorm:"-"`                          //搴撳瓨浣嶇疆
+		Contacts               string       `json:"contacts" gorm:"type:varchar(255);comment:鑱旂郴浜�"`       //鑱旂郴浜�
 	}
 
 	WarehouseSearch struct {
@@ -35,6 +38,7 @@
 		Keyword  string
 		Orm      *gorm.DB
 		Preload  bool
+		Codes    []string
 	}
 )
 
@@ -66,13 +70,18 @@
 	return slf
 }
 
-func (slf *WarehouseSearch) SetID(id uint) *WarehouseSearch {
-	slf.ID = id
+func (slf *WarehouseSearch) SetID(id int) *WarehouseSearch {
+	slf.Id = id
 	return slf
 }
 
 func (slf *WarehouseSearch) SetCode(code string) *WarehouseSearch {
 	slf.Code = code
+	return slf
+}
+
+func (slf *WarehouseSearch) SetCodes(codes []string) *WarehouseSearch {
+	slf.Codes = codes
 	return slf
 }
 
@@ -92,10 +101,10 @@
 }
 
 func (slf *WarehouseSearch) build() *gorm.DB {
-	var db = slf.Orm.Model(&Warehouse{})
+	var db = slf.Orm.Table(slf.TableName())
 
-	if slf.ID != 0 {
-		db = db.Where("id = ?", slf.ID)
+	if slf.Id != 0 {
+		db = db.Where("id = ?", slf.Id)
 	}
 
 	if slf.Order != "" {
@@ -112,6 +121,14 @@
 
 	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
@@ -175,7 +192,7 @@
 
 func (slf *WarehouseSearch) Delete() error {
 	var db = slf.build()
-	return db.Delete(&Warehouse{}).Error
+	return db.Unscoped().Delete(&Warehouse{}).Error
 }
 
 func (slf *WarehouseSearch) First() (*Warehouse, error) {

--
Gitblit v1.8.0