From e8c60100b28e1cead3ce4f6a99ab111a58b2ecdb Mon Sep 17 00:00:00 2001
From: zhangqian <zhangqian@123.com>
Date: 星期五, 13 十月 2023 13:49:31 +0800
Subject: [PATCH] 联系人简单数据权限
---
api/v1/contact.go | 10 ++++++++++
model/contact.go | 7 ++++---
2 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/api/v1/contact.go b/api/v1/contact.go
index 7daace8..1a72e6b 100644
--- a/api/v1/contact.go
+++ b/api/v1/contact.go
@@ -1,11 +1,13 @@
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"
)
@@ -159,6 +161,14 @@
return
}
+ userInfo := utils.GetUserInfo(c)
+ if userInfo.UserType == constvar.UserTypeSub {
+ if params.SearchMap == nil {
+ params.SearchMap = make(map[string]interface{}, 0)
+ }
+ params.SearchMap["member_id"] = userInfo.CrmUserId
+ }
+
contacts, total, errCode := contactService.GetContactList(params.Page, params.PageSize, params.SearchMap)
if errCode != ecode.OK {
ctx.Fail(errCode)
diff --git a/model/contact.go b/model/contact.go
index 01c2732..025137f 100644
--- a/model/contact.go
+++ b/model/contact.go
@@ -92,9 +92,10 @@
db = db.Where("is_first = ?", false)
}
}
- case int:
- case int64:
- case float64:
+ case int, uint, int64, float64:
+ if key == "id" || key == "client_type_id" || key == "client_status_id" || key == "member_id" {
+ db = db.Where(key+" = ?", v)
+ }
if key == "client_id" {
db = db.Where("client_id = ? and is_first = true", v)
}
--
Gitblit v1.8.0