From 8be40ffd79c4dcdb4dc00bef359ccf48a6b031f3 Mon Sep 17 00:00:00 2001
From: zhangqian <zhangqian@123.com>
Date: 星期六, 28 十月 2023 15:56:26 +0800
Subject: [PATCH] 若干接口支持查看下属数据

---
 api/v1/client.go |   31 +++++++++++++++++++++++--------
 1 files changed, 23 insertions(+), 8 deletions(-)

diff --git a/api/v1/client.go b/api/v1/client.go
index 6e45eb2..d7dc42e 100644
--- a/api/v1/client.go
+++ b/api/v1/client.go
@@ -28,19 +28,28 @@
 		return
 	}
 
+	if params.MemberId == 0 {
+		userInfo := utils.GetUserInfo(c)
+		if userInfo.UserType == constvar.UserTypeSub {
+			params.MemberId = userInfo.CrmUserId
+		}
+	}
+
 	errCode, client := checkClientParams(params.Client)
 	if errCode != ecode.OK {
 		ctx.Fail(errCode)
 		return
 	}
 
-	//CreatorId, b := c.Get("claims")
-	//if !b {
-	//	ctx.Fail(ecode.JWTParseErr)
-	//	return
-	//}
-	//
-	//client.CreatorId = CreatorId.(int)
+	count, err := model.NewClientSearch(nil).SetNumber(client.Number).Count()
+	if err != nil {
+		ctx.FailWithMsg(ecode.UnknownErr, "缂栫爜楠岃瘉澶辫触")
+		return
+	}
+	if count > 0 {
+		ctx.FailWithMsg(ecode.UnknownErr, "缂栫爜宸插瓨鍦�")
+		return
+	}
 
 	errCode = clientService.AddClient(client, params.SalesLeadsId)
 	if errCode != ecode.OK {
@@ -107,7 +116,13 @@
 	client.Business.IndustryId = params.IndustryId
 	client.Business.EnterpriseNatureId = params.EnterpriseNatureId
 	client.Business.EnterpriseScaleId = params.EnterpriseScaleId
-	client.MemberId = params.MemberId
+	//閿�鍞礋璐d汉涓虹┖鏃朵负鍏捣瀹㈡埛
+	if params.MemberId == 0 {
+		client.MemberId = 1
+	} else {
+		client.MemberId = params.MemberId
+	}
+	client.CodeStandID = params.CodeStandID
 
 	//if params.Contact.Name != "" {
 	// assign the client's member id to contact when adding

--
Gitblit v1.8.0