Browse Source

Merge remote-tracking branch 'origin/eta/2.3' into debug

Roc 3 months ago
parent
commit
9125b919b2

+ 41 - 3
controllers/data_manage/edb_info_share.go

@@ -7,6 +7,7 @@ import (
 	"eta_gn/eta_api/models/data_manage"
 	"eta_gn/eta_api/models/data_manage/request"
 	"eta_gn/eta_api/models/data_manage/response"
+	"eta_gn/eta_api/models/system"
 	"eta_gn/eta_api/services/data"
 	"eta_gn/eta_api/services/elastic"
 	"eta_gn/eta_api/utils"
@@ -167,7 +168,7 @@ func (c *EdbInfoShareController) Tree() {
 		nodeList, err := data.GetEdbClassifyItemListByShareEdbInfoQueryList(sendList)
 		if err != nil {
 			br.Msg = "获取失败"
-			br.ErrMsg = "获取我共享的指标列表分类结构信息失败,Err:" + err.Error()
+			br.ErrMsg = "获取我共享出去的指标列表分类结构信息失败,Err:" + err.Error()
 			return
 		}
 		resp.Send = nodeList
@@ -185,7 +186,7 @@ func (c *EdbInfoShareController) Tree() {
 		nodeList, err := data.GetEdbClassifyItemListByShareEdbInfoQueryList(sendList)
 		if err != nil {
 			br.Msg = "获取失败"
-			br.ErrMsg = "获取我共享的指标列表分类结构信息失败,Err:" + err.Error()
+			br.ErrMsg = "获取我收到共享的指标列表分类结构信息失败,Err:" + err.Error()
 			return
 		}
 
@@ -205,7 +206,7 @@ func (c *EdbInfoShareController) Tree() {
 					RootId:           0,
 					Level:            0,
 					Sort:             0,
-					UniqueCode:       "",
+					UniqueCode:       utils.MD5(fmt.Sprint(v.SysUserId, "_", v.SysUserRealName)),
 					Source:           0,
 					SourceName:       "",
 					SysUserId:        v.SysUserId,
@@ -418,14 +419,20 @@ func (c *EdbInfoShareController) ListByEs() {
 
 	// 因为是ES查找的,所以需要重新查一下指标的信息,主要是为了把是否授权字段找出来
 	if len(edbInfoList) > 0 {
+		sysUserIdList := make([]int, 0)
 		edbInfoIdList := make([]int, 0)
 		for _, v := range edbInfoList {
 			v.ConvertToResp()
 			v.EdbNameAlias = v.EdbName
 			v.HaveOperaAuth = true
 			edbInfoIdList = append(edbInfoIdList, v.EdbInfoId)
+
+			if v.SharedUserIdList != nil && len(v.SharedUserIdList) > 0 {
+				sysUserIdList = append(sysUserIdList, v.SharedUserIdList...)
+			}
 		}
 
+		// 获取指标数据
 		tmpEdbList, err := data_manage.GetEdbInfoByIdList(edbInfoIdList)
 		if err != nil {
 			br.Msg = "获取失败"
@@ -437,12 +444,43 @@ func (c *EdbInfoShareController) ListByEs() {
 			edbInfoMap[v.EdbInfoId] = v
 		}
 
+		// 获取用户数据
+		sysUserMap := make(map[int]string)
+		if len(sysUserIdList) > 0 {
+			sysUserList, err := system.GetAdminListByIdList(sysUserIdList)
+			if err != nil {
+				br.Msg = "获取失败"
+				br.ErrMsg = "获取分享用户列表失败,Err:" + err.Error()
+				return
+			}
+
+			for _, v := range sysUserList {
+				sysUserMap[v.AdminId] = v.RealName
+			}
+		}
+
 		for _, v := range edbInfoList {
 			tmpEdbInfo, ok := edbInfoMap[v.EdbInfoId]
 			if !ok {
 				continue
 			}
 			v.IsJoinPermission = tmpEdbInfo.IsJoinPermission
+
+			// 分享人
+			shareUserName := ``
+			shareUserNameList := make([]string, 0)
+			for _, userId := range v.SharedUserIdList {
+				userName, ok := sysUserMap[userId]
+				if !ok {
+					continue
+				}
+				shareUserNameList = append(shareUserNameList, userName)
+			}
+			if len(shareUserNameList) > 0 {
+				shareUserName = strings.Join(shareUserNameList, `,`)
+			}
+			v.SharedUserName = shareUserName
+
 		}
 	}
 

+ 18 - 4
controllers/fix.go

@@ -133,7 +133,11 @@ func initFixSelfEdbClassify(classifyType int) {
 		}
 		hasClassifyIdStrList = append(hasClassifyIdStrList, v.ClassifyIdPath)
 	}
-	classifyIdStrList := strings.Split(strings.Join(hasClassifyIdStrList, ","), ",")
+
+	classifyIdStrList := make([]string, 0)
+	if len(hasClassifyIdStrList) > 0 {
+		classifyIdStrList = strings.Split(strings.Join(hasClassifyIdStrList, ","), ",")
+	}
 	classifyIdMap := make(map[string]bool)
 	for _, v := range classifyIdStrList {
 		classifyIdMap[v] = true
@@ -256,7 +260,10 @@ func deleteNullEdbClassify(classifyType int) {
 	for _, v := range hasEdbClassifyList {
 		hasClassifyIdStrList = append(hasClassifyIdStrList, v.ClassifyIdPath)
 	}
-	classifyIdStrList := strings.Split(strings.Join(hasClassifyIdStrList, ","), ",")
+	classifyIdStrList := make([]string, 0)
+	if len(hasClassifyIdStrList) > 0 {
+		classifyIdStrList = strings.Split(strings.Join(hasClassifyIdStrList, ","), ",")
+	}
 	for _, v := range classifyIdStrList {
 		classifyId, err := strconv.Atoi(v)
 		if err != nil {
@@ -425,7 +432,10 @@ func initFixSelfChartClassify() {
 		}
 		hasClassifyIdStrList = append(hasClassifyIdStrList, v.ChartClassifyIdPath)
 	}
-	classifyIdStrList := strings.Split(strings.Join(hasClassifyIdStrList, ","), ",")
+	classifyIdStrList := make([]string, 0)
+	if len(hasClassifyIdStrList) > 0 {
+		classifyIdStrList = strings.Split(strings.Join(hasClassifyIdStrList, ","), ",")
+	}
 	classifyIdMap := make(map[string]bool)
 	for _, v := range classifyIdStrList {
 		classifyIdMap[v] = true
@@ -547,7 +557,11 @@ func deleteNullChartClassify() {
 	for _, v := range hasEdbClassifyList {
 		hasClassifyIdStrList = append(hasClassifyIdStrList, v.ChartClassifyIdPath)
 	}
-	classifyIdStrList := strings.Split(strings.Join(hasClassifyIdStrList, ","), ",")
+
+	classifyIdStrList := make([]string, 0)
+	if len(hasClassifyIdStrList) > 0 {
+		classifyIdStrList = strings.Split(strings.Join(hasClassifyIdStrList, ","), ",")
+	}
 	for _, v := range classifyIdStrList {
 		classifyId, err := strconv.Atoi(v)
 		if err != nil {

+ 1 - 0
models/data_manage/edb_info.go

@@ -412,6 +412,7 @@ type EdbInfoList struct {
 	IsSupplierStop        int                     `description:"是否供应商停更:1:停更,0:未停更"`
 	CollectClassifyIdList []int                   `description:"所属收藏分类id列表" gorm:"-"`
 	SharedUserIdList      []int                   `description:"共享用户id列表" gorm:"-"`
+	SharedUserName        string                  `description:"共享用户姓名,多个用英文,隔开" gorm:"-"`
 	PublicStatus          int                     `description:"公开状态;0:未公开;1:审批中;2:已驳回;3:已公开"`
 	EdbPublicClassifyId   int                     `description:"指标公开分类id"`
 	PublicTime            time.Time               `description:"设置公开的时间"`

+ 3 - 1
services/data/edb_info_share.go

@@ -101,7 +101,9 @@ func GetEdbClassifyItemListByShareEdbInfoQueryList(items []*data_manage.ShareEdb
 		for _, v := range classifyItemsList {
 			allClassifyIdStrList = append(allClassifyIdStrList, v.ClassifyIdPath)
 		}
-		allClassifyIdStrList = strings.Split(strings.Join(allClassifyIdStrList, ","), ",")
+		if len(allClassifyIdStrList) > 0 {
+			allClassifyIdStrList = strings.Split(strings.Join(allClassifyIdStrList, ","), ",")
+		}
 		for _, v := range allClassifyIdStrList {
 			classifyId, tmpErr := strconv.Atoi(v)
 			if tmpErr != nil {