From 6becb6b281b34e17197a25af86acd35628e88811 Mon Sep 17 00:00:00 2001
From: jiangshuai <291802688@qq.com>
Date: 星期三, 20 九月 2023 17:51:18 +0800
Subject: [PATCH] Merge branch 'master' of http://192.168.5.5:10010/r/aps/WMS

---
 models/warehouse.go |   42 +++++++++++++++++++++++++-----------------
 1 files changed, 25 insertions(+), 17 deletions(-)

diff --git a/models/warehouse.go b/models/warehouse.go
index c6cd670..8e8a779 100644
--- a/models/warehouse.go
+++ b/models/warehouse.go
@@ -11,17 +11,22 @@
 	// Warehouse 浠撳簱
 	Warehouse struct {
 		WmsModel
-		Id               int          `json:"id" gorm:"column:id;primary_key;AUTO_INCREMENT"`
-		Name             string       `json:"name" gorm:"index;type:varchar(255);not null;comment:浠撳簱鍚嶇О"`                                 //浠撳簱鍚嶇О
-		Active           bool         `json:"active" gorm:"type:tinyint(1);not null;comment:鏄惁婵�娲�"`                                       //鏄惁鍚敤锛屼紶true灏辫
-		Code             string       `json:"code" binding:"required,min=1,max=5"  gorm:"index;type:varchar(255);not null;comment:浠撳簱缂栫爜"` //浠撳簱缂栫爜
-		PartnerID        int          `json:"partnerId"  gorm:"type:int;not null;comment:鍚堜綔浼欎即id"`                                        //鍚堜綔浼欎即id
-		BuyToResupply    bool         `json:"buyToResupply" gorm:"type:tinyint(1);not null;comment:鏄惁璐拱琛ョ粰"`                              //鏄惁璐拱琛ョ粰锛屽凡璐拱浜у搧鑳藉鍙戦�佸埌姝や粨搴�
-		ResupplyWhIdsStr string       `json:"-" gorm:"column:resupply_wh_ids;type:varchar(255);not null;comment:琛ョ粰鏉ユ簮浠撳簱ID"`               //琛ョ粰鏉ユ簮浠撳簱ID
-		ResupplyWhIds    []string     `json:"resupplyWhIds" gorm:"-"`                                                                    //琛ョ粰鏉ユ簮浠撳簱ID
-		ResupplyWh       []*Warehouse `json:"resupplyWh" gorm:"-"`                                                                       //琛ョ粰鏉ユ簮浠撳簱
-		CompanyId        int          `json:"companyId" gorm:"type:int;not null;comment:鍏徃id"`
-		Company          Company      `json:"company" gorm:"foreignKey:CompanyId"`
+		Id                     int          `json:"id" gorm:"column:id;primary_key;AUTO_INCREMENT"`
+		Name                   string       `json:"name" gorm:"index;type:varchar(255);not null;comment:浠撳簱鍚嶇О"`                                 //浠撳簱鍚嶇О
+		Active                 bool         `json:"active" gorm:"type:tinyint(1);not null;comment:鏄惁婵�娲�"`                                       //鏄惁鍚敤锛屼紶true灏辫
+		Code                   string       `json:"code" binding:"required,min=1,max=5"  gorm:"index;type:varchar(255);not null;comment:浠撳簱缂栫爜"` //浠撳簱缂栫爜
+		PartnerID              int          `json:"partnerId"  gorm:"type:int;not null;comment:鍚堜綔浼欎即id"`                                        //鍚堜綔浼欎即id
+		BuyToResupply          bool         `json:"buyToResupply" gorm:"type:tinyint(1);not null;comment:鏄惁璐拱琛ョ粰"`                              //鏄惁璐拱琛ョ粰锛屽凡璐拱浜у搧鑳藉鍙戦�佸埌姝や粨搴�
+		ResupplyWhIdsStr       string       `json:"-" gorm:"column:resupply_wh_ids;type:varchar(255);not null;comment:琛ョ粰鏉ユ簮浠撳簱ID"`               //琛ョ粰鏉ユ簮浠撳簱ID
+		ResupplyWhIds          []string     `json:"resupplyWhIds" gorm:"-"`                                                                    //琛ョ粰鏉ユ簮浠撳簱ID
+		ResupplyWh             []*Warehouse `json:"resupplyWh" gorm:"-"`                                                                       //琛ョ粰鏉ユ簮浠撳簱
+		CompanyId              int          `json:"companyId" gorm:"type:int;not null;comment:鍏徃id"`
+		Company                Company      `json:"company" gorm:"foreignKey:CompanyId"`
+		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:"-"`                          //搴撳瓨浣嶇疆
 	}
 
 	WarehouseSearch struct {
@@ -63,8 +68,8 @@
 	return slf
 }
 
-func (slf *WarehouseSearch) SetID(id uint) *WarehouseSearch {
-	slf.ID = id
+func (slf *WarehouseSearch) SetID(id int) *WarehouseSearch {
+	slf.Id = id
 	return slf
 }
 
@@ -89,10 +94,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 != "" {
@@ -109,6 +114,9 @@
 
 	if slf.Preload {
 		db = db.Preload("Company")
+	}
+	if slf.Code != "" {
+		db = db.Where("code = ?", slf.Code)
 	}
 
 	return db
@@ -172,7 +180,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