Browse Source

Merge branch 'feature/v1.0.1' of https://jygit.jydev.jianyu360.cn/moapp/jy_docs into feature/v1.0.1

wangshan 1 year ago
parent
commit
06b8accc4a

+ 5 - 3
rpc/stdlib/etc/stdlib.yaml

@@ -13,12 +13,14 @@ EsConfig:
   Password: elastic
 Etcd:
   Hosts:
-    - 127.0.0.1:2379
+    - 192.168.3.206:2379
   Key: jydocs.stdlib.rpc
 FileSystemConf:
   Hosts:
-    - 192.168.3.240:2379
+    - 192.168.3.206:2379
   Key: moapp.filesystem.rpc
 DocBucketName: "jydoc-stdlib"
 PreviewBucketName: "jydoc-preview"
-Timeout: 4000
+Timeout: 4000
+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

@@ -36,7 +36,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 {
 	startNow := time.Now()
 	defer common.Catch()
 	in.KeyWord = strings.TrimSpace(in.KeyWord)
@@ -81,6 +81,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 != "" {