From e0a433e9c31594527a3bf7766c0bfb2cbbceffdb Mon Sep 17 00:00:00 2001
From: wangpengfei <274878379@qq.com>
Date: 星期三, 26 七月 2023 10:09:04 +0800
Subject: [PATCH] fix add pageInfo, keyword to all the list

---
 model/quotation.go |   26 +++++++++++++++++++++++++-
 1 files changed, 25 insertions(+), 1 deletions(-)

diff --git a/model/quotation.go b/model/quotation.go
index 878f211..d14bc36 100644
--- a/model/quotation.go
+++ b/model/quotation.go
@@ -28,7 +28,13 @@
 	// QuotationSearch 鎶ヤ环鍗曟悳绱㈡潯浠�
 	QuotationSearch struct {
 		Quotation
-		Orm *gorm.DB
+
+				Orm      *gorm.DB
+		Keyword  string
+		OrderBy  string
+		PageNum  int
+		PageSize int
+
 	}
 )
 
@@ -44,6 +50,9 @@
 
 func (slf *QuotationSearch) build() *gorm.DB {
 	var db = slf.Orm.Model(&Quotation{})
+	if slf.Keyword != "" {
+		db = db.Where("name LIKE ?", "%"+slf.Keyword+"%")
+	}
 	if slf.Id != 0 {
 		db = db.Where("id = ?", slf.Id)
 	}
@@ -89,3 +98,18 @@
 	var db = slf.build()
 	return db.Updates(data).Error
 }
+
+func (slf *QuotationSearch) SetKeyword(keyword string) *QuotationSearch {
+	slf.Keyword = keyword
+	return slf
+}
+
+func (slf *QuotationSearch) SetPage(page, size int) *QuotationSearch {
+	slf.PageNum, slf.PageSize = page, size
+	return slf
+}
+
+func (slf *QuotationSearch) SetOrder(order string) *QuotationSearch {
+	slf.OrderBy = order
+	return slf
+}

--
Gitblit v1.8.0