From b4400a06b5f801bc7a85320680d0b6c45c547ff0 Mon Sep 17 00:00:00 2001
From: wangpengfei <274878379@qq.com>
Date: 星期五, 28 七月 2023 10:21:33 +0800
Subject: [PATCH] fix

---
 api/v1/followRecord.go |  126 +++++++++++++++++++++--------------------
 1 files changed, 64 insertions(+), 62 deletions(-)

diff --git a/api/v1/followRecord.go b/api/v1/followRecord.go
index 8000585..e6c2f4c 100644
--- a/api/v1/followRecord.go
+++ b/api/v1/followRecord.go
@@ -6,7 +6,6 @@
 	"aps_crm/model/response"
 	"aps_crm/pkg/contextx"
 	"aps_crm/pkg/ecode"
-	"aps_crm/service"
 	"github.com/gin-gonic/gin"
 	"strconv"
 	"time"
@@ -42,30 +41,6 @@
 	}
 
 	ctx.Ok()
-}
-
-// List
-//
-//	@Tags		FollowRecord
-//	@Summary	鑾峰彇璺熻繘璁板綍鍒楄〃
-//	@Produce	application/json
-//	@Success	200	{object}	contextx.Response{data=response.FollowRecordResponse}
-//	@Router		/api/followRecord/list [get]
-func (fr *FollowRecordApi) List(c *gin.Context) {
-	ctx, ok := contextx.NewContext(c, nil)
-	if !ok {
-		return
-	}
-
-	errCode, followRecordList := followRecordService.GetFollowRecordList()
-	if errCode != ecode.OK {
-		ctx.Fail(errCode)
-		return
-	}
-
-	ctx.OkWithDetailed(response.FollowRecordResponse{
-		List: followRecordList,
-	})
 }
 
 // Delete
@@ -128,42 +103,42 @@
 func checkFollowRecordParams(followRecord request.FollowRecord) (int, *model.FollowRecord) {
 	var followRecordModel model.FollowRecord
 
-	if followRecord.ClientId != 0 {
-		// check client exist
-		if service.CheckClientExist(followRecord.ClientId) != ecode.OK {
-			return ecode.ClientNotExist, &followRecordModel
-		}
-	}
-
-	if followRecord.ContactId != 0 {
-		// check contact exist
-		if service.CheckContactExist(followRecord.ContactId) != ecode.OK {
-			return ecode.ContactNotExist, &followRecordModel
-		}
-	}
-
-	if followRecord.SalesLeadsId != 0 {
-		// check sales leads exist
-		if service.CheckSalesLeadsExist(followRecord.SalesLeadsId) != ecode.OK {
-			return ecode.SalesLeadsNotExist, &followRecordModel
-		}
-	}
-
-	// check member id
-	if followRecord.MemberId == 0 {
-		// todo check member exist
-		return ecode.InvalidParams, &followRecordModel
-	}
-
-	// check number
-	if followRecord.Number == "" {
-		return ecode.InvalidParams, &followRecordModel
-	}
-
-	// check follow content
-	if followRecord.Content == "" {
-		return ecode.InvalidParams, &followRecordModel
-	}
+	//if followRecord.ClientId != 0 {
+	//	// check client exist
+	//	if service.CheckClientExist(followRecord.ClientId) != ecode.OK {
+	//		return ecode.ClientNotExist, &followRecordModel
+	//	}
+	//}
+	//
+	//if followRecord.ContactId != 0 {
+	//	// check contact exist
+	//	if service.CheckContactExist(followRecord.ContactId) != ecode.OK {
+	//		return ecode.ContactNotExist, &followRecordModel
+	//	}
+	//}
+	//
+	//if followRecord.SalesLeadsId != 0 {
+	//	// check sales leads exist
+	//	if service.CheckSalesLeadsExist(followRecord.SalesLeadsId) != ecode.OK {
+	//		return ecode.SalesLeadsNotExist, &followRecordModel
+	//	}
+	//}
+	//
+	//// check member id
+	//if followRecord.MemberId == 0 {
+	//	// todo check member exist
+	//	return ecode.InvalidParams, &followRecordModel
+	//}
+	//
+	//// check number
+	//if followRecord.Number == "" {
+	//	return ecode.InvalidParams, &followRecordModel
+	//}
+	//
+	//// check follow content
+	//if followRecord.Content == "" {
+	//	return ecode.InvalidParams, &followRecordModel
+	//}
 
 	// check follow time
 	t, err := checkTimeFormat(followRecord.FollowTime)
@@ -200,7 +175,7 @@
 // 妫�鏌ユ椂闂存牸寮�
 func checkTimeFormat(t string) (time.Time, error) {
 	if t == "" {
-		t = "1970-01-01T00:00:00+08:00"
+		t = "1900-01-01T00:00:00+08:00"
 	}
 
 	location, err := time.LoadLocation("Asia/Shanghai")
@@ -220,3 +195,30 @@
 
 	return time.Time{}, err
 }
+
+// List
+//
+//	@Tags		FollowRecord
+//	@Summary	鍥炶璁板綍鍒楄〃
+//	@Produce	application/json
+//	@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
+	ctx, ok := contextx.NewContext(c, &params)
+	if !ok {
+		return
+	}
+
+	followRecords, total, errCode := followRecordService.GetFollowRecordList(params.Page, params.PageSize, params.Keyword)
+	if errCode != ecode.OK {
+		ctx.Fail(errCode)
+		return
+	}
+
+	ctx.OkWithDetailed(response.FollowRecordResponse{
+		List:  followRecords,
+		Count: int(total),
+	})
+}
\ No newline at end of file

--
Gitblit v1.8.0