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项目模块信息

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

diff --git a/api/v1/contact.go b/api/v1/contact.go
index 2fd3dd4..97068ca 100644
--- a/api/v1/contact.go
+++ b/api/v1/contact.go
@@ -1,13 +1,14 @@
 package v1
 
 import (
+	"aps_crm/constvar"
 	"aps_crm/model"
 	"aps_crm/model/request"
 	"aps_crm/model/response"
 	"aps_crm/pkg/contextx"
 	"aps_crm/pkg/ecode"
+	"aps_crm/utils"
 	"github.com/gin-gonic/gin"
-	"strconv"
 )
 
 type ContactApi struct{}
@@ -33,11 +34,25 @@
 		return
 	}
 
+	if params.MemberId == 0 {
+		userInfo := utils.GetUserInfo(c)
+		if userInfo.UserType == constvar.UserTypeSub {
+			params.MemberId = userInfo.CrmUserId
+		}
+	}
+
 	errCode = contactService.AddContact(&contact)
 	if errCode != ecode.OK {
 		ctx.Fail(errCode)
 		return
 	}
+	//if params.CodeRule.Method == 1 {
+	//	autoCode := model.GetAutoCode(contact.Id, &params.CodeRule)
+	//	m := map[string]interface{}{
+	//		"number": autoCode,
+	//	}
+	//	_ = model.NewContactSearch(nil).SetId(contact.Id).UpdateByMap(m)
+	//}
 
 	ctx.Ok()
 }
@@ -47,17 +62,17 @@
 //	@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
@@ -142,6 +157,7 @@
 	contact.Birthday = t
 	contact.Wechat = params.Wechat
 	contact.IsFirst = params.IsFirst
+	//contact.CodeStandID = params.CodeStandID
 	return ecode.OK, contact
 }
 
@@ -160,7 +176,15 @@
 		return
 	}
 
-	contacts, total, errCode := contactService.GetContactList(params.Page, params.PageSize, params.Keyword)
+	userInfo := utils.GetUserInfo(c)
+	if userInfo.UserType == constvar.UserTypeSub {
+		if params.SearchMap == nil {
+			params.SearchMap = make(map[string]interface{}, 0)
+		}
+		params.SearchMap["member_ids"] = userInfo.SubUserIds
+	}
+
+	contacts, total, errCode := contactService.GetContactList(params.Page, params.PageSize, params.SearchMap, params.ClientId)
 	if errCode != ecode.OK {
 		ctx.Fail(errCode)
 		return
@@ -170,4 +194,4 @@
 		List:  contacts,
 		Count: int(total),
 	})
-}
\ No newline at end of file
+}

--
Gitblit v1.8.0