wangshan vor 9 Monaten
Ursprung
Commit
6ee38e3057
1 geänderte Dateien mit 21 neuen und 2 gelöschten Zeilen
  1. 21 2
      jyBXCore/rpc/service/purchase.go

+ 21 - 2
jyBXCore/rpc/service/purchase.go

@@ -163,6 +163,26 @@ func (p *Purchase) PurchaseListFormat(res []map[string]interface{}) (list []*bxc
 		area := MC.InterfaceToStr(rv["area"])
 		city := MC.InterfaceToStr(rv["city"])
 		district := MC.InterfaceToStr(rv["district"])
+		title := MC.InterfaceToStr(rv["title"])
+		if len([]rune(title)) > 50 {
+			splitStr := "-"
+			titles := strings.Split(title, splitStr)
+			lastPart := ""
+			if len(titles) > 1 {
+				lastPart = titles[len(titles)-1]
+				if lastPart == city || lastPart == area || lastPart == district {
+					title = strings.Join(titles[:len(titles)-1], splitStr)
+				} else {
+					lastPart = ""
+				}
+			}
+			if len([]rune(title)) > 50 {
+				title = string([]rune(title)[:50])
+			}
+			if lastPart != "" {
+				title = fmt.Sprintf("%s%s%s", title, splitStr, lastPart)
+			}
+		}
 		regionUrl := ""
 		if district != "" && IC.DistrictMap[district] != "" {
 			regionUrl = fmt.Sprintf(AreaLabelLink, "city", IC.DistrictMap[district])
@@ -227,7 +247,7 @@ func (p *Purchase) PurchaseListFormat(res []map[string]interface{}) (list []*bxc
 			BuyerClass:  MC.InterfaceToStr(rv["buyerclass"]),
 			PublishTime: MC.Int64All(rv["publishtime"]),
 			FileExists:  isValidFile,
-			Title:       MC.InterfaceToStr(rv["title"]),
+			Title:       title,
 			Price:       price,
 			Buyer:       buyer,
 			BuyerTel:    buyerTel,
@@ -449,7 +469,6 @@ func (p *Purchase) FindDataFromES() (int64, []map[string]interface{}, error) {
 		HighLight:  false, //是否高亮正文
 	}
 	total, list = biddingSearch.GetAllByNgramWithCount(es.LoginTypePay)
-	log.Println(total, "---------222----------", list)
 	if total == 0 || list == nil {
 		log.Println(fmt.Errorf("暂无数据"))
 		return 0, nil, nil