浏览代码

仅首页返回total

wangkaiyue 4 年之前
父节点
当前提交
0b250ec3db

+ 5 - 4
src/jfw/modules/publicapply/src/enterpriseSearch/entity/entQuery.go

@@ -22,9 +22,7 @@ type EnterpriseSearch struct {
 
 	PageSize int  //每页数量
 	PageNum  int  //页码
-	Total    int  //一共多少条
 	IsVip    bool //是否是会员
-
 }
 
 const (
@@ -129,10 +127,13 @@ func (es *EnterpriseSearch) GetQuerySql() string {
 func (es *EnterpriseSearch) DoQuery() (list *[]map[string]interface{}, total int64, err error) {
 	sql := es.GetQuerySql()
 	log.Println("EnterpriseSearch DoQuery sql", sql)
+
 	start, limit := es.PageNum*es.PageSize, es.PageSize
+	total = -1
+
 	if !es.IsVip {
-		start, limit, total = 0, freeSearchNum, -1
-	} else if total == 0 {
+		start, limit = 0, freeSearchNum
+	} else if start == 0 {
 		if total = elastic.Count(index, itype, sql); total == 0 {
 			return
 		}

+ 7 - 5
src/jfw/modules/publicapply/src/enterpriseSearch/service/search.go

@@ -32,7 +32,6 @@ func (esa *EnterpriseSearchAction) DoEntSearch() {
 			EntContact:  esa.GetString("entContact"),
 			PageSize:    qutil.IntAll(esa.GetString("pageSize")),
 			PageNum:     qutil.IntAll(esa.GetString("pageNum")),
-			Total:       qutil.IntAll(esa.GetString("total")),
 		}).Check()
 		if err != nil {
 			return nil, err
@@ -46,10 +45,13 @@ func (esa *EnterpriseSearchAction) DoEntSearch() {
 		if err != nil {
 			return nil, err
 		}
-		return map[string]interface{}{
-			"total": total,
-			"list":  searchList,
-		}, nil
+		returnData := map[string]interface{}{
+			"list": searchList,
+		}
+		if total >= 0 {
+			returnData["total"] = total
+		}
+		return returnData, nil
 	}()
 	if errMsg != nil {
 		log.Printf("%s EnterpriseSearchAction DoEntSearch异常:%s\n", userId, errMsg.Error())