From 9a7e0a7da01a9f9625ceaca0c61a59c540c6438f Mon Sep 17 00:00:00 2001
From: wangpengfei <274878379@qq.com>
Date: 星期五, 18 八月 2023 17:32:10 +0800
Subject: [PATCH] fix

---
 api/v1/contact.go |   62 ++++++++++++++++---------------
 1 files changed, 32 insertions(+), 30 deletions(-)

diff --git a/api/v1/contact.go b/api/v1/contact.go
index 001ecc9..7daace8 100644
--- a/api/v1/contact.go
+++ b/api/v1/contact.go
@@ -7,7 +7,6 @@
 	"aps_crm/pkg/contextx"
 	"aps_crm/pkg/ecode"
 	"github.com/gin-gonic/gin"
-	"strconv"
 )
 
 type ContactApi struct{}
@@ -47,47 +46,23 @@
 //	@Tags		Contact
 //	@Summary	鍒犻櫎鑱旂郴浜�
 //	@Produce	application/json
-//	@Param		id	path		int	true	"鏌ヨ鍙傛暟"
+//	@Param		object	body		request.DeleteContact true	"鏌ヨ鍙傛暟"
 //	@Success	200	{object}	contextx.Response{}
-//	@Router		/api/contact/delete/{id} [delete]
+//	@Router		/api/contact/delete [delete]
 func (con *ContactApi) Delete(c *gin.Context) {
-	ctx, ok := contextx.NewContext(c, nil)
+	var params request.DeleteContact
+	ctx, ok := contextx.NewContext(c, &params)
 	if !ok {
 		return
 	}
 
-	id, _ := strconv.Atoi(c.Param("id"))
-	errCode := contactService.DeleteContact(id)
+	errCode := contactService.DeleteContact(params.Ids)
 	if errCode != ecode.OK {
 		ctx.Fail(errCode)
 		return
 	}
 
 	ctx.Ok()
-}
-
-// List
-//
-//	@Tags		Contact
-//	@Summary	鑱旂郴浜哄垪琛�
-//	@Produce	application/json
-//	@Success	200	{object}	contextx.Response{data=response.ContactResponse}
-//	@Router		/api/contact/list [get]
-func (con *ContactApi) List(c *gin.Context) {
-	ctx, ok := contextx.NewContext(c, nil)
-	if !ok {
-		return
-	}
-
-	contacts, errCode := contactService.GetContactList()
-	if errCode != ecode.OK {
-		ctx.Fail(errCode)
-		return
-	}
-
-	ctx.OkWithDetailed(response.ContactResponse{
-		List: contacts,
-	})
 }
 
 // Update
@@ -168,3 +143,30 @@
 	contact.IsFirst = params.IsFirst
 	return ecode.OK, contact
 }
+
+// List
+//
+//	@Tags		Contact
+//	@Summary	鑱旂郴浜哄垪琛�
+//	@Produce	application/json
+//	@Param		object	body		request.GetContactList	true	"鍙傛暟"
+//	@Success	200		{object}	contextx.Response{data=response.ContactResponse}
+//	@Router		/api/contact/list [post]
+func (con *ContactApi) List(c *gin.Context) {
+	var params request.GetContactList
+	ctx, ok := contextx.NewContext(c, &params)
+	if !ok {
+		return
+	}
+
+	contacts, total, errCode := contactService.GetContactList(params.Page, params.PageSize, params.SearchMap)
+	if errCode != ecode.OK {
+		ctx.Fail(errCode)
+		return
+	}
+
+	ctx.OkWithDetailed(response.ContactResponse{
+		List:  contacts,
+		Count: int(total),
+	})
+}

--
Gitblit v1.8.0