From be953da6ecba5036e63eac2bb5851e04dca1e8f7 Mon Sep 17 00:00:00 2001
From: wangpengfei <274878379@qq.com>
Date: 星期五, 11 八月 2023 14:06:56 +0800
Subject: [PATCH] fix

---
 model/collectionProjection.go |   29 +++++++++++++++++++++++++----
 1 files changed, 25 insertions(+), 4 deletions(-)

diff --git a/model/collectionProjection.go b/model/collectionProjection.go
index 2e160a2..de10709 100644
--- a/model/collectionProjection.go
+++ b/model/collectionProjection.go
@@ -19,10 +19,11 @@
 	CollectionProjectionSearch struct {
 		CollectionProjection
 
-		Orm      *gorm.DB
-		OrderBy  string
-		PageNum  int
-		PageSize int
+		Orm       *gorm.DB
+		SearchMap map[string]interface{}
+		OrderBy   string
+		PageNum   int
+		PageSize  int
 	}
 )
 
@@ -40,6 +41,21 @@
 	var db = slf.Orm.Model(&CollectionProjection{})
 	if slf.Id != 0 {
 		db = db.Where("id = ?", slf.Id)
+	}
+
+	if len(slf.SearchMap) > 0 {
+		for key, value := range slf.SearchMap {
+			switch v := value.(type) {
+			case string:
+				if key == "estimated_collection_date" {
+					db = db.Where(key+" = ?", v)
+				}
+			case int:
+				if key == "client_id" {
+					db = db.Where(key+" = ?", v)
+				}
+			}
+		}
 	}
 
 	return db
@@ -92,3 +108,8 @@
 	slf.PageNum, slf.PageSize = page, size
 	return slf
 }
+
+func (slf *CollectionProjectionSearch) SetSearchMap(data map[string]interface{}) *CollectionProjectionSearch {
+	slf.SearchMap = data
+	return slf
+}

--
Gitblit v1.8.0