From aeed976c2999e2cea097cdee38d8baeefe323f3d Mon Sep 17 00:00:00 2001 From: liujiandao <274878379@qq.com> Date: 星期六, 30 三月 2024 16:15:59 +0800 Subject: [PATCH] 修改 --- models/operation.go | 46 +++++++++++++++++++++++++++++++++------------- 1 files changed, 33 insertions(+), 13 deletions(-) diff --git a/models/operation.go b/models/operation.go index c16e13a..1296457 100644 --- a/models/operation.go +++ b/models/operation.go @@ -14,7 +14,7 @@ WmsModel Id int `json:"id" gorm:"column:id;primary_key;AUTO_INCREMENT"` Number string `json:"number" gorm:"type:varchar(255)"` //鍗曞彿 - SourceNumber string `json:"sourceNumber" gorm:"type:varchar(255)"` //婧愬崟鍙� + SourceNumber string `json:"sourceNumber" gorm:"index;type:varchar(255)"` //婧愬崟鍙� OperationTypeId int `json:"operationTypeId" gorm:"type:int;not null;comment:浣滀笟绫诲瀷id"` //浣滀笟绫诲瀷id OperationTypeName string `json:"operationTypeName" gorm:"type:varchar(127);comment:浣滀笟绫诲瀷鍚嶇О"` //浣滀笟绫诲瀷鍚嶇О Status constvar.OperationStatus `json:"status" gorm:"type:int(11);not null;comment:鐘舵��"` //鐘舵�� @@ -22,18 +22,19 @@ //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"` //鐩爣浣嶇疆 - OperationDate string `json:"operationDate" gorm:"type:varchar(31);comment:瀹夋帓鏃ユ湡"` - ContacterID int `json:"contacterID" gorm:"type:int;comment:鑱旂郴浜篒D"` - ContacterName string `json:"contacterName" gorm:"type:varchar(63);comment:鑱旂郴浜哄鍚�"` - CompanyID int `json:"companyID" gorm:"type:int;comment:鍏徃ID-瀹㈡埛"` - CompanyName string `json:"companyName" gorm:"type:varchar(127);comment:鍏徃鍚嶇О-瀹㈡埛"` - Comment string `json:"comment" gorm:"type:text;comment:澶囨敞"` - LogisticCompanyId string `json:"logisticCompanyId" gorm:"type:varchar(191);comment:鐗╂祦鍏徃id"` - LogisticCompany LogisticCompany `json:"logisticCompany" gorm:"foreignKey:LogisticCompanyId"` - WaybillNumber string `json:"waybillNumber" gorm:"type:varchar(255);comment:杩愬崟鍙�"` //杩愬崟鍙� - Weight decimal.Decimal `gorm:"type:decimal(20,2);comment:閲嶉噺" json:"weight"` //閲嶉噺 - LogisticWeight decimal.Decimal `gorm:"type:decimal(20,2);comment:鐗╂祦閲嶉噺" json:"logisticWeight"` //鐗╂祦閲嶉噺 - Source string `json:"source" gorm:"type:varchar(255);comment:鏉ユ簮绯荤粺,鐢ㄤ簬杩斿洖淇敼鐘舵��"` + OperationDate string `json:"operationDate" gorm:"type:varchar(31);comment:瀹夋帓鏃ユ湡"` + ContacterID int `json:"contacterID" gorm:"type:int;comment:鑱旂郴浜篒D"` + ContacterName string `json:"contacterName" gorm:"type:varchar(63);comment:鑱旂郴浜哄鍚�"` + CompanyID int `json:"companyID" gorm:"type:int;comment:鍏徃ID-瀹㈡埛"` + CompanyName string `json:"companyName" gorm:"type:varchar(127);comment:鍏徃鍚嶇О-瀹㈡埛"` + Comment string `json:"comment" gorm:"type:text;comment:澶囨敞"` + LogisticCompanyId string `json:"logisticCompanyId" gorm:"type:varchar(191);comment:鐗╂祦鍏徃id"` + LogisticCompany LogisticCompany `json:"logisticCompany" gorm:"foreignKey:LogisticCompanyId"` + WaybillNumber string `json:"waybillNumber" gorm:"type:varchar(255);comment:杩愬崟鍙�"` //杩愬崟鍙� + Weight decimal.Decimal `gorm:"type:decimal(20,2);comment:閲嶉噺" json:"weight"` //閲嶉噺 + LogisticWeight decimal.Decimal `gorm:"type:decimal(20,2);comment:鐗╂祦閲嶉噺" json:"logisticWeight"` //鐗╂祦閲嶉噺 + Source string `json:"source" gorm:"type:varchar(255);comment:鏉ユ簮绯荤粺,鐢ㄤ簬杩斿洖淇敼鐘舵��"` + OperationSource constvar.OperationSource `json:"operationSource" gorm:"type:tinyint(3);not null;default:0;comment:鎿嶄綔鏉ユ簮"` //鎿嶄綔鏉ユ簮 Details []*OperationDetails `json:"details" gorm:"foreignKey:OperationID;references:Id"` BaseOperationType constvar.BaseOperationType `json:"baseOperationType" gorm:"type:tinyint;not null;comment:鍩虹浣滀笟绫诲瀷"` //鍩虹浣滀笟绫诲瀷 @@ -142,6 +143,11 @@ return slf } +func (slf *OperationSearch) SetOperationSource(operationSource constvar.OperationSource) *OperationSearch { + slf.OperationSource = operationSource + return slf +} + func (slf *OperationSearch) build() *gorm.DB { var db = slf.Orm.Model(&Operation{}) @@ -190,6 +196,10 @@ if slf.SalesDetailsNumber != "" { db = db.Where("sales_details_number = ?", slf.SalesDetailsNumber) + } + + if slf.OperationSource != 0 { + db = db.Where("operation_source = ?", slf.OperationSource) } return db @@ -364,3 +374,13 @@ } return int(total), nil } + +func (slf *OperationSearch) Count() (int64, error) { + var ( + total int64 + db = slf.build() + ) + + err := db.Count(&total).Error + return total, err +} -- Gitblit v1.8.0