浏览代码

默认值处理

WH01243 7 月之前
父节点
当前提交
f800df66ac
共有 2 个文件被更改,包括 10 次插入6 次删除
  1. 3 2
      jyBXCore/rpc/internal/logic/operatorsearchlogic.go
  2. 7 4
      jyBXCore/rpc/service/operator.go

+ 3 - 2
jyBXCore/rpc/internal/logic/operatorsearchlogic.go

@@ -49,10 +49,11 @@ func (l *OperatorSearchLogic) OperatorSearch(in *bxcore.OperatorSearchReq) (*bxc
 		PositionId:   in.PositionId,
 		Order:        in.Order,
 	}
-	count, data := service.SearchList(operator)
+	count, data, total := service.SearchList(operator)
 	result := map[string]interface{}{
 		"list":  data,
-		"total": count,
+		"total": total,
+		"count": count,
 	}
 	infoByte, _ := json.Marshal(result)
 	return &bxcore.OperatorSearchResp{

+ 7 - 4
jyBXCore/rpc/service/operator.go

@@ -1,6 +1,7 @@
 package service
 
 import (
+	"app.yhyue.com/moapp/jybase/common"
 	elastic "app.yhyue.com/moapp/jybase/es"
 	IC "bp.jydev.jianyu360.cn/BaseService/jyMicroservices/jyBXCore/rpc/init"
 	"fmt"
@@ -501,7 +502,7 @@ type Operator struct {
 	Order        int64
 }
 
-func SearchList(operator Operator) (int64, *[]map[string]interface{}) {
+func SearchList(operator Operator) (int64, *[]map[string]interface{}, int64) {
 	if operator.PageSize == 0 {
 		operator.PageSize = 10
 	}
@@ -578,7 +579,7 @@ func SearchList(operator Operator) (int64, *[]map[string]interface{}) {
 		if operator.WordsMode == 1 {
 			keyArr := []string{}
 			for _, v := range strings.Split(operator.KeyWords, ",") {
-				keyArr = append(keyArr, fmt.Sprintf(`{"match_phrase":{"%s":"%s"}`, operator.SelectType, v))
+				keyArr = append(keyArr, fmt.Sprintf(`{"match_phrase":{"%s":"%s"}}`, operator.SelectType, v))
 			}
 			mustArr = append(mustArr, fmt.Sprintf(shouldStr, strings.Join(keyArr, ",")))
 		} else {
@@ -832,9 +833,11 @@ func SearchList(operator Operator) (int64, *[]map[string]interface{}) {
 		fmt.Println(sqlStr, idArr)
 		data = IC.BiMysql.SelectBySql(sqlStr,
 			idArr...)
-		return count, data
+		total := count
+		count = gconv.Int64(common.If(count > 2000, 2000, count))
+		return count, data, total
 	} else {
-		return count, &[]map[string]interface{}{}
+		return count, &[]map[string]interface{}{}, 0
 	}
 
 }