瀏覽代碼

feat:供应信息搜索

wangshan 3 年之前
父節點
當前提交
965ee59670
共有 1 個文件被更改,包括 23 次插入10 次删除
  1. 23 10
      rpc/consumer/internal/logic/supplyinfosearchlogic.go

+ 23 - 10
rpc/consumer/internal/logic/supplyinfosearchlogic.go

@@ -1,13 +1,13 @@
 package logic
 
 import (
-	"context"
-	"strconv"
-	"strings"
-
 	IC "app.yhyue.com/moapp/jyInfo/rpc/consumer/init"
 	"app.yhyue.com/moapp/jyInfo/rpc/model/es"
 	"app.yhyue.com/moapp/jyInfo/rpc/util"
+	"context"
+	"fmt"
+	"strconv"
+	"strings"
 
 	se "app.yhyue.com/moapp/jybase/encrypt"
 
@@ -42,15 +42,28 @@ func (l *SupplyInfoSearchLogic) SupplyInfoSearch(in *consumerinfo.SupplyInfoSear
 	if in.PageIndex == 0 {
 		in.PageIndex = 1
 	}
-	//空格多个关键词
-	if strings.Contains(in.Keywords, "+") {
-		in.Keywords = strings.ReplaceAll(in.Keywords, " ", "+")
-	}
+	//空格多个关键词  以后可能会出现 关键词 C++ 等带+的关键词
+	//if strings.Contains(in.Keywords, "+") {
+	in.Keywords = strings.ReplaceAll(in.Keywords, " ", "+")
+	//}
 	list, total := model.GetSupplyInfoList(in, true)
 	logx.Info("ttt---", total, "----", in.Keywords)
-	if total == 0 && len([]rune(in.Keywords)) > 3 {
+	if in.PageIndex == 1 && total < in.PageSize && len([]rune(in.Keywords)) > 3 {
 		if secondKWS := util.HttpEsGetWords(in.Keywords, "ik_smart", IC.C.Es.Addr); secondKWS != "" {
-			in.Keywords = secondKWS
+			//分词后查询数据量有可能小于不分词查询数据量  -- 原因:未分词前是全文查询 分词后是标题查询;
+			secondKWS = fmt.Sprintf("%s+%s", in.Keywords, secondKWS)
+			var kbool = map[string]bool{}
+			var karr = []string{}
+			for _, v := range strings.Split(secondKWS, "+") {
+				if kbool[v] {
+					continue
+				}
+				karr = append(karr, v)
+				kbool[v] = true
+			}
+			in.Keywords = strings.Join(karr, "+")
+			in.PageSize = 100
+			//in.Keywords = secondKWS
 			list, total = model.GetSupplyInfoList(in, false)
 		}
 	}