From 530fed8ec225453572d57b15c200ab062c335457 Mon Sep 17 00:00:00 2001 From: zhangqian <zhangqian@123.com> Date: 星期三, 01 十一月 2023 19:20:21 +0800 Subject: [PATCH] 公海member_id使用0 --- model/receipt.go | 31 ++++++++++++++++++++++++------- 1 files changed, 24 insertions(+), 7 deletions(-) diff --git a/model/receipt.go b/model/receipt.go index 5c335a9..ff0a169 100644 --- a/model/receipt.go +++ b/model/receipt.go @@ -34,12 +34,13 @@ // ReceiptSearch 鏀舵鍗曟悳绱㈡潯浠� ReceiptSearch struct { Receipt - Orm *gorm.DB - QueryClass constvar.ReceiptQueryClass - KeywordType constvar.ReceiptKeywordType - Keyword string - PageNum int - PageSize int + Orm *gorm.DB + QueryClass constvar.ReceiptQueryClass + KeywordType constvar.ReceiptKeywordType + Keyword string + PageNum int + PageSize int + PrincipalIds []int } ) @@ -72,6 +73,11 @@ return slf } +func (slf *ReceiptSearch) SetPrincipalIds(principalIds []int) *ReceiptSearch { + slf.PrincipalIds = principalIds + return slf +} + func (slf *ReceiptSearch) SetPage(page, size int) *ReceiptSearch { slf.PageNum, slf.PageSize = page, size return slf @@ -87,6 +93,12 @@ } if slf.SourceId != 0 { db = db.Where("source_id = ?", slf.SourceId) + } + if slf.ClientId != 0 { + db = db.Where("client_id = ?", slf.ClientId) + } + if len(slf.PrincipalIds) != 0 { + db = db.Where("principal_id in ?", slf.PrincipalIds) } return db @@ -121,6 +133,11 @@ func (slf *ReceiptSearch) SetId(id int) *ReceiptSearch { slf.Id = id + return slf +} + +func (slf *ReceiptSearch) SetClientId(clientId int) *ReceiptSearch { + slf.ClientId = clientId return slf } @@ -165,7 +182,7 @@ db = db.Limit(slf.PageSize).Offset((slf.PageNum - 1) * slf.PageSize) } - err := db.Preload("Principal").Preload("Client").Preload("PaymentType").Preload("BankAccount").Find(&records).Error + err := db.Preload("Principal").Preload("Client").Preload("PaymentType").Preload("BankAccount").Order("created_at desc").Find(&records).Error return records, total, err } -- Gitblit v1.8.0