From 6e9274c27ffc8fe7f41e2c3c06a239d4c3fb09e5 Mon Sep 17 00:00:00 2001 From: zhangqian <zhangqian@123.com> Date: 星期三, 02 八月 2023 14:38:15 +0800 Subject: [PATCH] 增加服务回访单搜索条件 --- model/serviceFollowup.go | 40 ++++++++++++++++++++++++++++------------ 1 files changed, 28 insertions(+), 12 deletions(-) diff --git a/model/serviceFollowup.go b/model/serviceFollowup.go index c6baa40..23fda19 100644 --- a/model/serviceFollowup.go +++ b/model/serviceFollowup.go @@ -1,6 +1,7 @@ package model import ( + "aps_crm/constvar" "aps_crm/pkg/mysqlx" "gorm.io/gorm" ) @@ -28,13 +29,12 @@ ServiceFollowupSearch struct { ServiceFollowup - - Orm *gorm.DB - Keyword string - OrderBy string - PageNum int - PageSize int - + Orm *gorm.DB + KeywordType constvar.ServiceFollowupKeywordType + Keyword interface{} + OrderBy string + PageNum int + PageSize int } ) @@ -50,11 +50,24 @@ func (slf *ServiceFollowupSearch) build() *gorm.DB { var db = slf.Orm.Model(&ServiceFollowup{}) - if slf.Keyword != "" { - db = db.Where("name LIKE ?", "%"+slf.Keyword+"%") - } if slf.Id != 0 { db = db.Where("id = ?", slf.Id) + } + + switch slf.KeywordType { + case constvar.ServiceFollowupKeywordFollowupNo: + db = db.Where("number = ?", slf.Keyword) + case constvar.ServiceFollowupKeywordCustomerName: + db = db.Where("client_id = ?", slf.Keyword) + case constvar.ServiceFollowupKeywordContactName: + db = db.Where("contact_id = ?", slf.Keyword) + case constvar.ServiceFollowupKeywordCustomerServiceNo: + db = db.Where("service_id = ?", slf.Keyword) + case constvar.ServiceFollowupKeywordVisitor: + db = db.Where("member_id = ?", slf.Keyword) + case constvar.ServiceFollowupKeywordSatisfactionDegree: + db = db.Where("satisfaction_id = ?", slf.Keyword) + } return db @@ -106,7 +119,10 @@ return slf } -// 鍙兘鎬� 甯佺 褰撳墠鐘舵�侊紙閿�鍞満浼氾級 +func (slf *ServiceFollowupSearch) SetKeywordType(keyword constvar.ServiceFollowupKeywordType) *ServiceFollowupSearch { + slf.KeywordType = keyword + return slf +} func (slf *ServiceFollowupSearch) SetKeyword(keyword string) *ServiceFollowupSearch { slf.Keyword = keyword @@ -121,4 +137,4 @@ func (slf *ServiceFollowupSearch) SetOrder(order string) *ServiceFollowupSearch { slf.OrderBy = order return slf -} \ No newline at end of file +} -- Gitblit v1.8.0