From 87cad05224d857ec0e113ae03b006d2a52ec3049 Mon Sep 17 00:00:00 2001 From: zhangqian <zhangqian@123.com> Date: 星期三, 16 八月 2023 11:55:26 +0800 Subject: [PATCH] Merge branch 'zq' --- model/salesRefund.go | 36 ++++++++++++++++++++++++++++++++---- 1 files changed, 32 insertions(+), 4 deletions(-) diff --git a/model/salesRefund.go b/model/salesRefund.go index ef9b5ca..233aa72 100644 --- a/model/salesRefund.go +++ b/model/salesRefund.go @@ -15,11 +15,11 @@ ClientId int `json:"clientId" gorm:"column:client_id;type:int;comment:瀹㈡埛id"` Client Client `json:"client" gorm:"foreignKey:ClientId"` Number string `json:"number" gorm:"column:number;type:varchar(255);comment:閫�娆惧崟鍙�"` - SourceType constvar.RefundSourceType `gorm:"column:source_type;type:int;not null;default 0;comment:鏉ユ簮绫诲瀷锛�1閿�鍞槑缁嗗崟2鏈嶅姟鍚堝悓3閿�鍞彂绁�4鏀舵璁″垝5鍑哄簱鍗曪級" json:"sourceType"` // 鏉ユ簮绫诲瀷锛�1閿�鍞槑缁嗗崟2鏈嶅姟鍚堝悓3閿�鍞彂绁�4鏀舵璁″垝5鍑哄簱鍗曪級 - SourceId int `gorm:"column:source_id;type:int;not null;default 0;comment:婧愬崟id " json:"sourceId"` // 婧愬崟id + SourceType constvar.RefundSourceType `gorm:"column:source_type;type:int;not null;default 0;comment:鏉ユ簮绫诲瀷锛�1閿�鍞��璐э級" json:"sourceType"` // 鏉ユ簮绫诲瀷锛�1閿�鍞��璐э級 + SourceId int `gorm:"column:source_id;type:int;not null;default 0;comment:婧愬崟id " json:"sourceId"` // 婧愬崟id MemberId int `json:"memberId" gorm:"column:member_id;type:int;comment:璐熻矗浜篿d"` Member User `json:"member" gorm:"foreignKey:MemberId"` - RefundDate string `json:"refundDate" gorm:"column:refund_date;type:datetime;comment:閫�娆炬棩鏈�"` + RefundDate string `json:"refundDate" gorm:"column:refund_date;type:varchar(255);comment:閫�娆炬棩鏈�"` PaymentTypeId int `gorm:"column:payment_type_id;type:int;not null;default 0;comment:鏀舵鏂瑰紡ID" json:"paymentTypeId"` // 鏀舵鏂瑰紡ID PaymentType PaymentType `gorm:"foreignKey:PaymentTypeId" json:"paymentType"` BankAccountId int `gorm:"column:bank_account_id;type:int;not null;default 0;comment:璐︽埛id" json:"bankAccountId"` // 璐︽埛id @@ -40,6 +40,7 @@ PageNum int PageSize int Preload bool + Ids []int } ) @@ -57,6 +58,10 @@ var db = slf.Orm.Model(&SalesRefund{}) if slf.Id != 0 { db = db.Where("id = ?", slf.Id) + } + + if len(slf.Ids) != 0 { + db = db.Where("id in ?", slf.Ids) } if slf.Preload { @@ -107,11 +112,19 @@ return db.Updates(record).Error } -func (slf *SalesRefundSearch) Find() (*SalesRefund, error) { +func (slf *SalesRefundSearch) First() (*SalesRefund, error) { var db = slf.build() var record = new(SalesRefund) err := db.First(record).Error return record, err +} + +func (slf *SalesRefundSearch) Find() ([]*SalesRefund, error) { + var db = slf.build() + var records = make([]*SalesRefund, 0) + + err := db.Find(&records).Error + return records, err } func (slf *SalesRefundSearch) FindAll() ([]*SalesRefund, int64, error) { @@ -138,6 +151,21 @@ return slf } +func (slf *SalesRefundSearch) SetIds(id []int) *SalesRefundSearch { + slf.Ids = id + return slf +} + +func (slf *SalesRefundSearch) SetSourceType(sourceType constvar.RefundSourceType) *SalesRefundSearch { + slf.SourceType = sourceType + return slf +} + +func (slf *SalesRefundSearch) SetSourceId(id int) *SalesRefundSearch { + slf.SourceId = id + return slf +} + func (slf *SalesRefundSearch) SetPreload(preload bool) *SalesRefundSearch { slf.Preload = preload return slf -- Gitblit v1.8.0