From 99945ed9e1282863e435510abeced599fee4e02e Mon Sep 17 00:00:00 2001
From: zhangqian <zhangqian@123.com>
Date: 星期四, 10 八月 2023 19:48:14 +0800
Subject: [PATCH] 修改gorm字段

---
 model/quotation.go |   16 ++++++++++++----
 1 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/model/quotation.go b/model/quotation.go
index d14bc36..2999797 100644
--- a/model/quotation.go
+++ b/model/quotation.go
@@ -82,11 +82,19 @@
 	return &record, err
 }
 
-func (slf *QuotationSearch) FindAll() ([]*Quotation, error) {
+func (slf *QuotationSearch) FindAll() ([]*Quotation, int64, error) {
 	var db = slf.build()
-	var records []*Quotation
+	var records = make([]*Quotation, 0)
+	var total int64
+	if err := db.Count(&total).Error; err != nil {
+		return records, total, err
+	}
+	if slf.PageNum > 0 && slf.PageSize > 0 {
+		db = db.Limit(slf.PageSize).Offset((slf.PageNum - 1) * slf.PageSize)
+	}
+
 	err := db.Find(&records).Error
-	return records, err
+	return records, total, err
 }
 
 func (slf *QuotationSearch) SetId(id int) *QuotationSearch {
@@ -112,4 +120,4 @@
 func (slf *QuotationSearch) SetOrder(order string) *QuotationSearch {
 	slf.OrderBy = order
 	return slf
-}
+}
\ No newline at end of file

--
Gitblit v1.8.0