From 115bd9b51f5d8eade4658f844de37516486c60e7 Mon Sep 17 00:00:00 2001 From: liujiandao <274878379@qq.com> Date: 星期六, 18 十一月 2023 17:25:25 +0800 Subject: [PATCH] crm获取aps项目模块信息 --- model/serviceFollowup.go | 52 +++++++++++++++++++++++++++++++++++++++++++++++----- 1 files changed, 47 insertions(+), 5 deletions(-) diff --git a/model/serviceFollowup.go b/model/serviceFollowup.go index 3f457a6..65ffa14 100644 --- a/model/serviceFollowup.go +++ b/model/serviceFollowup.go @@ -41,11 +41,12 @@ ServiceFollowup Orm *gorm.DB KeywordType constvar.ServiceFollowupKeywordType - Keyword interface{} + Keyword string OrderBy string PageNum int PageSize int Preload bool + MemberIds []int } ) @@ -81,6 +82,10 @@ } + if slf.ServiceOrderId > 0 { + db = db.Where("service_order_id = ?", slf.ServiceOrderId) + } + if slf.Preload { db = db.Preload("Client"). Preload("Contact"). @@ -91,6 +96,13 @@ Preload("SolveRate"). Preload("IsVisit"). Preload("OldMember") + } + + if len(slf.MemberIds) > 0 { + db = db.Where("service_followup.member_id in ?", slf.MemberIds) + } + if slf.Number != "" { + db = db.Where("number = ?", slf.Number) } return db @@ -129,12 +141,37 @@ db = db.Limit(slf.PageSize).Offset((slf.PageNum - 1) * slf.PageSize) } - if slf.PageNum > 0 && slf.PageSize > 0 { - db = db.Limit(slf.PageSize).Offset((slf.PageNum - 1) * slf.PageSize) - } - err := db.Order("id desc").Find(&records).Error return records, total, err +} + +func (slf *ServiceFollowupSearch) Count() (int64, error) { + var db = slf.build() + var total int64 + err := db.Count(&total).Error + return total, err +} + +func (slf *ServiceFollowupSearch) MaxAutoIncr() (int, error) { + type Result struct { + Max int + } + + var ( + result Result + db = slf.build() + ) + + err := db.Select("MAX(id) as max").Scan(&result).Error + if err != nil { + return result.Max, fmt.Errorf("max err: %v", err) + } + return result.Max, nil +} + +func (slf *ServiceFollowupSearch) SetNumber(number string) *ServiceFollowupSearch { + slf.Number = number + return slf } func (slf *ServiceFollowupSearch) SetId(id int) *ServiceFollowupSearch { @@ -176,6 +213,11 @@ return slf } +func (slf *ServiceFollowupSearch) SetMemberIds(memberIds []int) *ServiceFollowupSearch { + slf.MemberIds = memberIds + return slf +} + func (slf *ServiceFollowupSearch) UpdateByMap(data map[string]interface{}) error { var db = slf.build() return db.Updates(data).Error -- Gitblit v1.8.0