瀏覽代碼

Merge branch 'bzq/knowledge_Bi' of eta_gn_server/eta_api into debug

baoziqiang 4 月之前
父節點
當前提交
9fb313fa21
共有 2 個文件被更改,包括 24 次插入5 次删除
  1. 16 4
      controllers/knowledge/resource.go
  2. 8 1
      services/knowledge/es.go

+ 16 - 4
controllers/knowledge/resource.go

@@ -337,9 +337,6 @@ func (this *ResourceController) Search() {
 		isIncludeFile = false
 	}
 	var searchUserIds []int
-	if IsShowMe {
-		searchUserIds = append(searchUserIds, this.SysUser.AdminId)
-	}
 	if addUserIds != "" {
 		// 转成数组,并把类型转成int
 		addUserIdsArr := strings.Split(addUserIds, ",")
@@ -348,6 +345,10 @@ func (this *ResourceController) Search() {
 			searchUserIds = append(searchUserIds, addUserId)
 		}
 	}
+	var myId int
+	if IsShowMe {
+		myId = this.SysUser.AdminId
+	}
 
 	var sourceFromArr []string
 	if sourceFrom != "" {
@@ -371,7 +372,18 @@ func (this *ResourceController) Search() {
 			tagIdsInt = append(tagIdsInt, tagId)
 		}
 	}
-	listTmp, total, err := knowledgeServ.SearchKnowledgeResourceByEs(resourceType, keyWord, searchUserIds, classifyIdsInt, sourceFromArr, tagIdsInt, isIncludeFile, startSize, pageSize)
+	listTmp, total, err := knowledgeServ.SearchKnowledgeResourceByEs(
+		resourceType,
+		keyWord,
+		searchUserIds,
+		myId,
+		classifyIdsInt,
+		sourceFromArr,
+		tagIdsInt,
+		isIncludeFile,
+		startSize,
+		pageSize,
+	)
 	if err != nil {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取失败,Err:" + err.Error()

+ 8 - 1
services/knowledge/es.go

@@ -14,7 +14,7 @@ import (
 )
 
 // SearchChartInfoData 查询es中的图表数据
-func SearchKnowledgeResourceByEs(resourceType int, keywordStr string, showSysIds, classifyIds []int, sourceList []string, tagIds []int, isIncludeFile bool, from, size int) (list []*knowledge.KnowledgeResource, total int64, err error) {
+func SearchKnowledgeResourceByEs(resourceType int, keywordStr string, showSysIds []int, myId int, classifyIds []int, sourceList []string, tagIds []int, isIncludeFile bool, from, size int) (list []*knowledge.KnowledgeResource, total int64, err error) {
 	indexName := utils.EsKnowledgeResourceIndexName
 	list = make([]*knowledge.KnowledgeResource, 0)
 	defer func() {
@@ -41,6 +41,13 @@ func SearchKnowledgeResourceByEs(resourceType int, keywordStr string, showSysIds
 			},
 		})
 	}
+	if myId > 0 {
+		mustMap = append(mustMap, map[string]interface{}{
+			"term": map[string]interface{}{
+				"AdminId": myId,
+			},
+		})
+	}
 	if len(tagIds) > 0 {
 		mustMap = append(mustMap, map[string]interface{}{
 			"terms": map[string]interface{}{