Forráskód Böngészése

Merge branch 'dev/v1.0.0.1_fu' of moapp/jy_docs into hotfix/v1.0.0.1

fuwencai 1 éve
szülő
commit
b74ebd5ad1

+ 2 - 0
rpc/stdlib/etc/stdlib.yaml

@@ -21,3 +21,5 @@ FileSystemConf:
   Key: moapp.filesystem.rpc
 DocBucketName: "jydoc-stdlib"
 PreviewBucketName: "jydoc-preview"
+SearchSource: # 文库搜索范围 1-剑鱼 2-豆丁
+  - "1" # 1-剑鱼 这配字符串方便拼接

+ 1 - 0
rpc/stdlib/internal/config/config.go

@@ -13,4 +13,5 @@ type Config struct {
 	EsConfig          jyDocRpcUtil.EsConfig
 	DocBucketName     string
 	PreviewBucketName string
+	SearchSource      []string // 文库搜索来源
 }

+ 1 - 1
rpc/stdlib/internal/logic/docquerylogic.go

@@ -51,5 +51,5 @@ func (l *DocQueryLogic) DocQuery(in *stdlib.DocQueryRequest) (*stdlib.DocQueryRe
 			}, nil
 		}
 	}
-	return stdlibService.DocQuery(in), nil
+	return stdlibService.DocQuery(in, l.svcCtx.Config.SearchSource), nil
 }

+ 4 - 1
services/stdlib/docService.go

@@ -33,7 +33,7 @@ func FindDocumentById(id int) {
 	log.Println(jyDocsRpcUtil.GetJyDocsDB().Exec("select * from ").Error)
 }
 
-func DocQuery(in *stdlib.DocQueryRequest) *stdlib.DocQueryResponse {
+func DocQuery(in *stdlib.DocQueryRequest, searchSource []string) *stdlib.DocQueryResponse {
 	defer common.Catch()
 	in.KeyWord = strings.TrimSpace(in.KeyWord)
 	musts := []string{}
@@ -69,6 +69,9 @@ func DocQuery(in *stdlib.DocQueryRequest) *stdlib.DocQueryResponse {
 		query_sort = fmt.Sprintf(Es_Query_Sort, strings.Join(sorts, ","))
 	}
 	query_append := fmt.Sprintf(Es_Query_Append, (in.PageNum-1)*in.PageSize, in.PageSize)
+	if searchSource != nil && len(searchSource) > 0 {
+		musts = append(musts, fmt.Sprintf(Terms, "source", strings.Join(searchSource, `,`)))
+	}
 	if len(musts) == 0 {
 		query = fmt.Sprintf(Es_Query_All, fmt.Sprint(query_append, query_sort))
 	} else if in.KeyWord != "" {