From 3c921c53c2b4dcd617a4ec88bd2a78fe69f2b600 Mon Sep 17 00:00:00 2001 From: wangpengfei <274878379@qq.com> Date: 星期四, 10 八月 2023 19:34:33 +0800 Subject: [PATCH] temp --- model/collectionProjection.go | 17 +++++++++++++---- 1 files changed, 13 insertions(+), 4 deletions(-) diff --git a/model/collectionProjection.go b/model/collectionProjection.go index c289864..e6d758b 100644 --- a/model/collectionProjection.go +++ b/model/collectionProjection.go @@ -11,7 +11,7 @@ SaleChanceId int `json:"sale_chance_id" gorm:"column:sale_chance_id;type:int(11);comment:閿�鍞満浼歩d"` Creator int `json:"creator" gorm:"column:creator;type:int(11);comment:鍒涘缓浜�"` Modifier int `json:"modifier" gorm:"column:modifier;type:int(11);comment:淇敼浜�"` - EstimatedCollectionDate string `json:"estimated_collection_date" gorm:"column:estimated_collection_date;type:datetime;comment:棰勮鏀舵鏃ユ湡"` + EstimatedCollectionDate *string `json:"estimated_collection_date" gorm:"column:estimated_collection_date;type:datetime;comment:棰勮鏀舵鏃ユ湡"` EstimatedCollectionAmount float64 `json:"estimated_collection_amount" gorm:"column:estimated_collection_amount;type:decimal(10,2);comment:棰勮鏀舵閲戦"` gorm.Model } @@ -63,10 +63,19 @@ return } -func (slf *CollectionProjectionSearch) Find() (record CollectionProjection, err error) { +func (slf *CollectionProjectionSearch) Find() (int64, error, []*CollectionProjection) { var db = slf.build() - err = db.First(&record).Error - return + var records = make([]*CollectionProjection, 0) + var total int64 + if err := db.Count(&total).Error; err != nil { + return total, err, records + } + if slf.PageNum > 0 && slf.PageSize > 0 { + db = db.Offset((slf.PageNum - 1) * slf.PageSize).Limit(slf.PageSize) + } + + err := db.Find(&records).Error + return total, err, records } func (slf *CollectionProjectionSearch) SetID(id int) *CollectionProjectionSearch { -- Gitblit v1.8.0