Răsfoiți Sursa

报告列表搜索页为空的时候返回空数组

xingzai 2 ani în urmă
părinte
comite
ec6f67621e
2 a modificat fișierele cu 11 adăugiri și 4 ștergeri
  1. 8 2
      controllers/home.go
  2. 3 2
      controllers/search.go

+ 8 - 2
controllers/home.go

@@ -1,7 +1,6 @@
 package controllers
 
 import (
-	"fmt"
 	"github.com/rdlucklib/rdluck_tools/paging"
 	"hongze/hongze_clpt/models"
 	"hongze/hongze_clpt/services"
@@ -133,6 +132,10 @@ func (this *MobileHomeController) List() {
 		chartList[k].IsNeedJump = true
 		chartList[k].Source = 2
 	}
+
+	if len(chartList) == 0 {
+		chartList = make([]*models.HomeChartListResp, 0)
+	}
 	resp.ChartList = chartList
 
 	if listType != 3 {
@@ -219,7 +222,6 @@ func (this *MobileHomeController) List() {
 			item := list[k]
 			//如果文章一开始的内容是图片,优先展示第一张图片
 			imgurl, _ := services.FixArticleImgUrl(html.UnescapeString(list[k].Body))
-			fmt.Println(item.Annotation)
 			newBody, _ := services.GetReportContentTextSubByarticle(item.Body, item.Annotation, item.ArticleId)
 			list[k].Annotation = newBody
 			list[k].Body = ""
@@ -246,6 +248,10 @@ func (this *MobileHomeController) List() {
 			}
 			list[k].Source = 1
 		}
+
+		if len(list) == 0 {
+			list = make([]*models.HomeArticle, 0)
+		}
 		resp.List = list
 	}
 	if chartTotal > total {

+ 3 - 2
controllers/search.go

@@ -185,18 +185,19 @@ func (this *MobileSearchController) ListHomeArtAndChart() {
 	} else {
 		source = 2
 	}
-
 	//如果是有效用户就记录搜索历史
 	if user.UserId > 0 {
 		go services.AddSearchKeyWord(user, keyWord, source)
 	}
-
 	if chartTotal > int(total) {
 		total = int64(chartTotal)
 	}
 	if listType == 1 {
 		total = total + int64(chartTotal)
 	}
+	if len(result) == 0 {
+		result = make([]*models.SearchItem, 0)
+	}
 	page := paging.GetPaging(currentIndex, pageSize, int(total))
 	resp.Paging = page
 	resp.List = result