From 7e0823fc3b352cfcbb4a2f21088c00db2c00c395 Mon Sep 17 00:00:00 2001
From: wangpengfei <274878379@qq.com>
Date: 星期三, 02 八月 2023 17:29:27 +0800
Subject: [PATCH] fix

---
 model/followRecord.go |  374 +++++++++++++++++++++++++++--------------------------
 1 files changed, 189 insertions(+), 185 deletions(-)

diff --git a/model/followRecord.go b/model/followRecord.go
index 7107b14..352cd29 100644
--- a/model/followRecord.go
+++ b/model/followRecord.go
@@ -1,185 +1,189 @@
-package model
-
-import (
-	"aps_crm/pkg/mysqlx"
-	"gorm.io/gorm"
-	"time"
-)
-
-type (
-	FollowRecord struct {
-		Id                   int       `json:"id" gorm:"column:id;primary_key;AUTO_INCREMENT"`
-		ClientId             int       `json:"client_id" gorm:"column:client_id;type:int(11);comment:瀹㈡埛id"`
-		ClientStatusId       int       `json:"client_status_id" gorm:"column:client_status_id;type:int(11);comment:瀹㈡埛鐘舵�乮d"`
-		MemberId             int       `json:"member_id" gorm:"column:member_id;type:int(11);comment:璺熻繘浜篿d"`
-		Number               string    `json:"number" gorm:"column:number;type:varchar(255);comment:璺熻繘缂栧彿"`
-		ContactId            int       `json:"contact_id" gorm:"column:contact_id;type:int(11);comment:鑱旂郴浜篿d"`
-		Topic                string    `json:"topic" gorm:"column:topic;type:varchar(255);comment:璺熻繘涓婚"`
-		Record               string    `json:"record" gorm:"column:record;type:MEDIUMTEXT;comment:璺熻繘璁板綍"`
-		SaleChanceId         int       `json:"sale_chance_id" gorm:"column:sale_chance_id;type:int(11);comment:閿�鍞満浼歩d"`
-		SalesLeadsId         int       `json:"sales_leads_id" gorm:"column:sales_leads_id;type:int(11);comment:閿�鍞嚎绱d"`
-		ContactInformationId int       `json:"contact_information_id" gorm:"column:contact_information_id;type:int(11);comment:鑱旂郴鏂瑰紡id"`
-		FollowTime           time.Time `json:"follow_time" gorm:"column:follow_time;type:datetime;comment:璺熻繘鏃堕棿"`
-		NextFollowTime       time.Time `json:"next_follow_time" gorm:"column:next_follow_time;type:datetime;comment:涓嬫璺熻繘鏃堕棿"`
-		Purpose              string    `json:"purpose" gorm:"column:purpose;type:varchar(255);comment:璺熻繘鐩殑"`
-		Content              string    `json:"content" gorm:"column:content;type:MEDIUMTEXT;comment:璺熻繘鍐呭"`
-		Client               Client    `json:"client" gorm:"foreignKey:ClientId"`
-		Contact              Contact   `json:"contact" gorm:"foreignKey:ContactId"`
-		gorm.Model           `json:"-"`
-	}
-
-	FollowRecordSearch struct {
-		FollowRecord
-
-		Orm      *gorm.DB
-		Keyword  string
-		OrderBy  string
-		PageNum  int
-		PageSize int
-	}
-)
-
-func (FollowRecord) TableName() string {
-	return "follow_records"
-}
-
-func NewFollowRecordSearch() *FollowRecordSearch {
-	return &FollowRecordSearch{
-		Orm: mysqlx.GetDB(),
-	}
-}
-
-func (slf *FollowRecordSearch) build() *gorm.DB {
-	var db = slf.Orm.Model(&FollowRecord{})
-	if slf.Keyword != "" {
-		db = db.Where("name LIKE ?", "%"+slf.Keyword+"%")
-	}
-	if slf.Keyword != "" {
-		db = db.Where("topic LIKE ?", "%"+slf.Keyword+"%")
-	}
-	if slf.Id != 0 {
-		db = db.Where("id = ?", slf.Id)
-	}
-	if slf.ClientId != 0 {
-		db = db.Where("client_id = ?", slf.ClientId)
-	}
-	if slf.ClientStatusId != 0 {
-		db = db.Where("client_status_id = ?", slf.ClientStatusId)
-	}
-	if slf.MemberId != 0 {
-		db = db.Where("member_id = ?", slf.MemberId)
-	}
-	if slf.Number != "" {
-		db = db.Where("number = ?", slf.Number)
-	}
-	if slf.ContactId != 0 {
-		db = db.Where("contact_id = ?", slf.ContactId)
-	}
-	if slf.Topic != "" {
-		db = db.Where("topic = ?", slf.Topic)
-	}
-	if slf.Record != "" {
-		db = db.Where("record = ?", slf.Record)
-	}
-	if slf.SaleChanceId != 0 {
-		db = db.Where("sale_chance_id = ?", slf.SaleChanceId)
-	}
-	if slf.SalesLeadsId != 0 {
-		db = db.Where("sales_leads_id = ?", slf.SalesLeadsId)
-	}
-	if slf.ContactInformationId != 0 {
-		db = db.Where("contact_information_id = ?", slf.ContactInformationId)
-	}
-	if !slf.FollowTime.IsZero() {
-		db = db.Where("follow_time = ?", slf.FollowTime)
-	}
-	if !slf.NextFollowTime.IsZero() {
-		db = db.Where("next_follow_time = ?", slf.NextFollowTime)
-	}
-	if slf.Purpose != "" {
-		db = db.Where("purpose = ?", slf.Purpose)
-	}
-	if slf.Content != "" {
-		db = db.Where("content = ?", slf.Content)
-	}
-
-	return db
-}
-
-func (slf *FollowRecordSearch) First() (*FollowRecord, error) {
-	var record = new(FollowRecord)
-	err := slf.build().First(record).Error
-	return record, err
-}
-
-func (slf *FollowRecordSearch) FindAll() ([]*FollowRecord, int64, error) {
-	var db = slf.build()
-	var records = make([]*FollowRecord, 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.Preload("Client").Preload("Contact").Find(&records).Error
-	return records, total, err
-}
-
-func (slf *FollowRecordSearch) Count() (int64, error) {
-	var count int64
-	err := slf.build().Count(&count).Error
-	return count, err
-}
-
-func (slf *FollowRecordSearch) Page(page, pageSize int) ([]*FollowRecord, int64, error) {
-	var records = make([]*FollowRecord, 0)
-	var count int64
-	err := slf.build().Count(&count).Error
-	if err != nil {
-		return records, count, err
-	}
-	err = slf.build().Offset((page - 1) * pageSize).Limit(pageSize).Find(&records).Error
-	return records, count, err
-}
-
-func (slf *FollowRecordSearch) Create(record *FollowRecord) error {
-	var db = slf.build()
-	return db.Create(record).Error
-}
-
-func (slf *FollowRecordSearch) Update(record *FollowRecord) error {
-	var db = slf.build()
-	return db.Updates(record).Error
-}
-
-func (slf *FollowRecordSearch) Delete() error {
-	var db = slf.build()
-	return db.Delete(&slf.FollowRecord).Error
-}
-
-func (slf *FollowRecordSearch) SetId(id int) *FollowRecordSearch {
-	slf.Id = id
-	return slf
-}
-
-func (slf *FollowRecordSearch) SetClientId(clientId int) *FollowRecordSearch {
-	slf.ClientId = clientId
-	return slf
-}
-
-func (slf *FollowRecordSearch) SetKeyword(keyword string) *FollowRecordSearch {
-	slf.Keyword = keyword
-	return slf
-}
-
-func (slf *FollowRecordSearch) SetPage(page, size int) *FollowRecordSearch {
-	slf.PageNum, slf.PageSize = page, size
-	return slf
-}
-
-func (slf *FollowRecordSearch) SetOrder(order string) *FollowRecordSearch {
-	slf.OrderBy = order
-	return slf
-}
+package model
+
+import (
+	"aps_crm/pkg/mysqlx"
+	"gorm.io/gorm"
+	"time"
+)
+
+type (
+	FollowRecord struct {
+		Id                   int       `json:"id" gorm:"column:id;primary_key;AUTO_INCREMENT"`
+		ClientId             int       `json:"client_id" gorm:"column:client_id;type:int(11);comment:瀹㈡埛id"`
+		ClientStatusId       int       `json:"client_status_id" gorm:"column:client_status_id;type:int(11);comment:瀹㈡埛鐘舵�乮d"`
+		MemberId             int       `json:"member_id" gorm:"column:member_id;type:int(11);comment:璺熻繘浜篿d"`
+		Number               string    `json:"number" gorm:"column:number;type:varchar(255);comment:璺熻繘缂栧彿"`
+		ContactId            int       `json:"contact_id" gorm:"column:contact_id;type:int(11);comment:鑱旂郴浜篿d"`
+		Topic                string    `json:"topic" gorm:"column:topic;type:varchar(255);comment:璺熻繘涓婚"`
+		Record               string    `json:"record" gorm:"column:record;type:MEDIUMTEXT;comment:璺熻繘璁板綍"`
+		SaleChanceId         int       `json:"sale_chance_id" gorm:"column:sale_chance_id;type:int(11);comment:閿�鍞満浼歩d"`
+		SalesLeadsId         int       `json:"sales_leads_id" gorm:"column:sales_leads_id;type:int(11);comment:閿�鍞嚎绱d"`
+		ContactInformationId int       `json:"contact_information_id" gorm:"column:contact_information_id;type:int(11);comment:鑱旂郴鏂瑰紡id"`
+		FollowTime           time.Time `json:"follow_time" gorm:"column:follow_time;type:datetime;comment:璺熻繘鏃堕棿"`
+		NextFollowTime       time.Time `json:"next_follow_time" gorm:"column:next_follow_time;type:datetime;comment:涓嬫璺熻繘鏃堕棿"`
+		Purpose              string    `json:"purpose" gorm:"column:purpose;type:varchar(255);comment:璺熻繘鐩殑"`
+		Content              string    `json:"content" gorm:"column:content;type:MEDIUMTEXT;comment:璺熻繘鍐呭"`
+		Client               Client    `json:"client" gorm:"foreignKey:ClientId"`
+		Contact              Contact   `json:"contact" gorm:"foreignKey:ContactId"`
+		gorm.Model           `json:"-"`
+	}
+
+	FollowRecordSearch struct {
+		FollowRecord
+
+		Orm      *gorm.DB
+		Keyword  string
+		OrderBy  string
+		PageNum  int
+		PageSize int
+	}
+)
+
+func (FollowRecord) TableName() string {
+	return "follow_records"
+}
+
+func NewFollowRecordSearch() *FollowRecordSearch {
+	return &FollowRecordSearch{
+		Orm: mysqlx.GetDB(),
+	}
+}
+
+func (slf *FollowRecordSearch) build() *gorm.DB {
+	var db = slf.Orm.Model(&FollowRecord{})
+	if slf.Keyword != "" {
+		db = db.Where("name LIKE ?", "%"+slf.Keyword+"%")
+	}
+	if slf.Keyword != "" {
+		db = db.Where("topic LIKE ?", "%"+slf.Keyword+"%")
+	}
+	if slf.Id != 0 {
+		db = db.Where("id = ?", slf.Id)
+	}
+	if slf.ClientId != 0 {
+		db = db.Where("client_id = ?", slf.ClientId)
+	}
+	if slf.ClientStatusId != 0 {
+		db = db.Where("client_status_id = ?", slf.ClientStatusId)
+	}
+	if slf.MemberId != 0 {
+		db = db.Where("member_id = ?", slf.MemberId)
+	}
+	if slf.Number != "" {
+		db = db.Where("number = ?", slf.Number)
+	}
+	if slf.ContactId != 0 {
+		db = db.Where("contact_id = ?", slf.ContactId)
+	}
+	if slf.Topic != "" {
+		db = db.Where("topic = ?", slf.Topic)
+	}
+	if slf.Record != "" {
+		db = db.Where("record = ?", slf.Record)
+	}
+	if slf.SaleChanceId != 0 {
+		db = db.Where("sale_chance_id = ?", slf.SaleChanceId)
+	}
+	if slf.SalesLeadsId != 0 {
+		db = db.Where("sales_leads_id = ?", slf.SalesLeadsId)
+	}
+	if slf.ContactInformationId != 0 {
+		db = db.Where("contact_information_id = ?", slf.ContactInformationId)
+	}
+	if !slf.FollowTime.IsZero() {
+		db = db.Where("follow_time = ?", slf.FollowTime)
+	}
+	if !slf.NextFollowTime.IsZero() {
+		db = db.Where("next_follow_time = ?", slf.NextFollowTime)
+	}
+	if slf.Purpose != "" {
+		db = db.Where("purpose = ?", slf.Purpose)
+	}
+	if slf.Content != "" {
+		db = db.Where("content = ?", slf.Content)
+	}
+
+	return db
+}
+
+func (slf *FollowRecordSearch) First() (*FollowRecord, error) {
+	var record = new(FollowRecord)
+	err := slf.build().First(record).Error
+	return record, err
+}
+
+func (slf *FollowRecordSearch) FindAll() ([]*FollowRecord, int64, error) {
+	var db = slf.build()
+	var records = make([]*FollowRecord, 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.Preload("Client").Preload("Contact").Find(&records).Error
+	return records, total, err
+}
+
+func (slf *FollowRecordSearch) Count() (int64, error) {
+	var count int64
+	err := slf.build().Count(&count).Error
+	return count, err
+}
+
+func (slf *FollowRecordSearch) Page(page, pageSize int) ([]*FollowRecord, int64, error) {
+	var records = make([]*FollowRecord, 0)
+	var count int64
+	err := slf.build().Count(&count).Error
+	if err != nil {
+		return records, count, err
+	}
+	err = slf.build().Offset((page - 1) * pageSize).Limit(pageSize).Find(&records).Error
+	return records, count, err
+}
+
+func (slf *FollowRecordSearch) Create(record *FollowRecord) error {
+	var db = slf.build()
+	return db.Create(record).Error
+}
+
+func (slf *FollowRecordSearch) Update(record *FollowRecord) error {
+	var db = slf.build()
+	return db.Updates(record).Error
+}
+
+func (slf *FollowRecordSearch) Delete() error {
+	var db = slf.build()
+	return db.Delete(&slf.FollowRecord).Error
+}
+
+func (slf *FollowRecordSearch) SetId(id int) *FollowRecordSearch {
+	slf.Id = id
+	return slf
+}
+
+func (slf *FollowRecordSearch) SetClientId(clientId int) *FollowRecordSearch {
+	slf.ClientId = clientId
+	return slf
+}
+
+func (slf *FollowRecordSearch) SetKeyword(keyword string) *FollowRecordSearch {
+	slf.Keyword = keyword
+	return slf
+}
+
+func (slf *FollowRecordSearch) SetPage(page, size int) *FollowRecordSearch {
+	slf.PageNum, slf.PageSize = page, size
+	return slf
+}
+
+func (slf *FollowRecordSearch) SetOrder(order string) *FollowRecordSearch {
+	slf.OrderBy = order
+	return slf
+}
+func (slf *FollowRecordSearch) SetIds(ids []int) *FollowRecordSearch {
+	slf.Orm = slf.Orm.Where("id in (?)", ids)
+	return slf
+}

--
Gitblit v1.8.0