From 8913004aaee4eba570ad48cff3c687349061d77a Mon Sep 17 00:00:00 2001
From: wangpengfei <274878379@qq.com>
Date: 星期四, 27 七月 2023 13:51:55 +0800
Subject: [PATCH] fix

---
 api/v1/serviceContract.go |    4 ++--
 service/followRecord.go   |   10 +++++-----
 api/v1/followRecord.go    |   10 +++++-----
 model/contact.go          |    0 
 model/followRecord.go     |    8 ++++++--
 5 files changed, 18 insertions(+), 14 deletions(-)

diff --git a/api/v1/followRecord.go b/api/v1/followRecord.go
index 698073a..e6c2f4c 100644
--- a/api/v1/followRecord.go
+++ b/api/v1/followRecord.go
@@ -201,8 +201,8 @@
 //	@Tags		FollowRecord
 //	@Summary	鍥炶璁板綍鍒楄〃
 //	@Produce	application/json
-//	@Param		object	body		request.GetFollowRecordList					true	"鍙傛暟"
-//	@Success	200	{object}	contextx.Response{data=response.FollowRecordResponse}
+//	@Param		object	body		request.GetFollowRecordList	true	"鍙傛暟"
+//	@Success	200		{object}	contextx.Response{data=response.FollowRecordResponse}
 //	@Router		/api/followRecord/list [post]
 func (fr *FollowRecordApi) List(c *gin.Context) {
 	var params request.GetFollowRecordList
@@ -211,7 +211,7 @@
 		return
 	}
 
-	followRecords, errCode := followRecordService.GetFollowRecordList(params.Page, params.PageSize, params.Keyword)
+	followRecords, total, errCode := followRecordService.GetFollowRecordList(params.Page, params.PageSize, params.Keyword)
 	if errCode != ecode.OK {
 		ctx.Fail(errCode)
 		return
@@ -219,6 +219,6 @@
 
 	ctx.OkWithDetailed(response.FollowRecordResponse{
 		List:  followRecords,
-		Count: len(followRecords),
+		Count: int(total),
 	})
-}
+}
\ No newline at end of file
diff --git a/api/v1/serviceContract.go b/api/v1/serviceContract.go
index 47a2e06..b9eabf3 100644
--- a/api/v1/serviceContract.go
+++ b/api/v1/serviceContract.go
@@ -154,8 +154,8 @@
 //	@Tags		ServiceContract
 //	@Summary	鐢熸垚璁″垝鍒楄〃
 //	@Produce	application/json
-//	@Param		object	body		request.GetServiceContractList					true	"鍙傛暟"
-//	@Success	200	{object}	contextx.Response{data=response.ServiceContractsResponse}
+//	@Param		object	body		request.GetServiceContractList	true	"鍙傛暟"
+//	@Success	200		{object}	contextx.Response{data=response.ServiceContractsResponse}
 //	@Router		/api/serviceContract/list [post]
 func (con *ServiceContractApi) List(c *gin.Context) {
 	var params request.GetServiceContractList
diff --git a/model/contacts.go b/model/contact.go
similarity index 100%
rename from model/contacts.go
rename to model/contact.go
diff --git a/model/followRecord.go b/model/followRecord.go
index fdadb48..b90aabe 100644
--- a/model/followRecord.go
+++ b/model/followRecord.go
@@ -112,15 +112,19 @@
 	return record, err
 }
 
-func (slf *FollowRecordSearch) Find() ([]*FollowRecord, error) {
+func (slf *FollowRecordSearch) FindAll() ([]*FollowRecord, int64, error) {
 	var db = slf.build()
 	var records = make([]*FollowRecord, 0)
 	if slf.PageNum > 0 && slf.PageSize > 0 {
 		db = db.Limit(slf.PageSize).Offset((slf.PageNum - 1) * slf.PageSize)
 	}
+	var total int64
+	if err := db.Count(&total).Error; err != nil {
+		return records, total, err
+	}
 
 	err := db.Preload("Client").Preload("Contact").Find(&records).Error
-	return records, err
+	return records, total, err
 }
 
 func (slf *FollowRecordSearch) Count() (int64, error) {
diff --git a/service/followRecord.go b/service/followRecord.go
index fd29b08..0fcc278 100644
--- a/service/followRecord.go
+++ b/service/followRecord.go
@@ -55,11 +55,11 @@
 	return ecode.OK
 }
 
-func (FollowRecordService) GetFollowRecordList(page, pageSize int, keyword string) ([]*model.FollowRecord, int) {
+func (FollowRecordService) GetFollowRecordList(page, pageSize int, keyword string) ([]*model.FollowRecord, int64, int) {
 	// get contact list
-	contacts, err := model.NewFollowRecordSearch().SetKeyword(keyword).SetPage(page, pageSize).Find()
+	contacts, total, err := model.NewFollowRecordSearch().SetKeyword(keyword).SetPage(page, pageSize).FindAll()
 	if err != nil {
-		return nil, ecode.FollowRecordListErr
+	return nil, 0, ecode.FollowRecordListErr
 	}
-	return contacts, ecode.OK
-}
+	return contacts, total, ecode.OK
+}
\ No newline at end of file

--
Gitblit v1.8.0