From 2e974a79678910d56e82aa2a8b2bf24f7ebc2d2d Mon Sep 17 00:00:00 2001
From: zhangqian <zhangqian@123.com>
Date: 星期五, 13 十月 2023 14:29:49 +0800
Subject: [PATCH] 报价单简单数据权限

---
 model/quotation.go  |    2 +-
 api/v1/quotation.go |   10 ++++++++++
 2 files changed, 11 insertions(+), 1 deletions(-)

diff --git a/api/v1/quotation.go b/api/v1/quotation.go
index a99f69a..edfb0ae 100644
--- a/api/v1/quotation.go
+++ b/api/v1/quotation.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"
 )
 
@@ -160,6 +162,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
+	}
+
 	quotations, total, errCode := quotationService.GetQuotationList(params.Page, params.PageSize, params.SearchMap)
 	if errCode != ecode.OK {
 		ctx.Fail(errCode)
diff --git a/model/quotation.go b/model/quotation.go
index 091c34b..6827e0d 100644
--- a/model/quotation.go
+++ b/model/quotation.go
@@ -79,7 +79,7 @@
 				}
 
 			case int:
-				if key == "client_id" || key == "sale_chance_id" {
+				if key == "client_id" || key == "sale_chance_id" || key == "member_id" {
 					db = db.Where(key+" = ?", v)
 				}
 			}

--
Gitblit v1.8.0