Przeglądaj źródła

返回结果调整

Jianghan 9 miesięcy temu
rodzic
commit
43f91bc8e9
1 zmienionych plików z 68 dodań i 8 usunięć
  1. 68 8
      api/internal/service/prListService.go

+ 68 - 8
api/internal/service/prListService.go

@@ -16,10 +16,10 @@ var (
 	esQ1      = `{"query": {"bool": {"must": [{"terms": {"buyer": ["%s"]}},{"terms": {"toptype": ["采购意向","预告","招标"]}}], "should": [%s], "minimum_should_match": 1}}, "_source": ["%s"], "sort": {"comeintime": {"order": "desc"}}, "from": %d, "size": %d}`
 	esQ2      = `{"query": {"bool": {"must": [{"terms": {"buyer": ["%s"]}},{"terms": {"toptype": ["采购意向","预告","招标"]}}]}}, "_source": ["%s"], "sort": {"comeintime": {"order": "desc"}}, "from": %d, "size": %d}`
 	shouldMul = `{"multi_match": {"query": "%s","type": "phrase", "fields": ["s_topscopeclass"]}}`
-	fields    = []string{"_id", "title", "publishtime", "dataweight", "detail", "site", "spidercode", "toptype", "subtype", "type", "area", "city", "s_topscopeclass", "s_subscopeclass", "bidamount", "budget", "buyerclass", "buyer", "winner", "bidopentime", "buyertel", "buyerperson", "agency", "agencytel", "agencyperson", "s_winner", "winnertel", "winnerperson", "signendtime", "bidendtime", "projectinfo", "entidlist"}
+	fields    = []string{"_id", "title", "publishtime", "dataweight", "detail", "site", "spidercode", "toptype", "subtype", "type", "area", "city", "district", "s_topscopeclass", "s_subscopeclass", "bidamount", "budget", "buyerclass", "buyer", "winner", "bidopentime", "buyertel", "buyerperson", "agency", "agencytel", "agencyperson", "s_winner", "winnertel", "winnerperson", "signendtime", "bidendtime", "projectinfo", "entidlist"}
 )
 
-func GetMonitorList(req *types.PrMonitorListReq) (resultList *[]map[string]interface{}, total int64) {
+func GetMonitorList(req *types.PrMonitorListReq) (resultList []map[string]interface{}, total int64) {
 
 	bList, b := T.Mgo.Find("follow_customer", map[string]string{"userId": req.MgoUserId}, `{_id: 1}`, nil, false, -1, -1)
 	if b && len(*bList) > 0 {
@@ -41,9 +41,13 @@ func GetMonitorList(req *types.PrMonitorListReq) (resultList *[]map[string]inter
 		} else {
 			esQuery1 = fmt.Sprintf(esQ2, strings.ReplaceAll(strings.Join(bName, ","), ",", `","`), strings.ReplaceAll(strings.Join(fields, ","), ",", `","`), pageStart, req.PageSize)
 		}
-		total, resultList = elastic.GetWithCount("bidding", "bidding", "", esQuery1)
-		for _, m := range *resultList {
-			m["_id"] = encrypt.CommonEncodeArticle("content", common.ObjToString(m["_id"]))
+		total, result := elastic.GetWithCount("bidding", "bidding", "", esQuery1)
+		if total == 0 {
+			return nil, 0
+		}
+		for _, m := range *result {
+			resultList = append(resultList, GetInfoData(m))
+
 		}
 		return
 	} else {
@@ -77,9 +81,8 @@ func GetCollectList(req *types.PrCollectListReq) (resultList []map[string]interf
 		for _, m := range *binfo {
 			if tp := common.ObjToString(m["toptype"]); tp == "采购意向" || tp == "预告" || tp == "招标" {
 				for _, s := range strings.Split(scopeClass, ",") {
-					if top := common.ObjToString("s_topscopeclass"); strings.Contains(top, s) {
-						m["_id"] = encrypt.CommonEncodeArticle("content", common.ObjToString(m["_id"]))
-						resultList = append(resultList, m)
+					if top := common.ObjToString(m["s_topscopeclass"]); strings.Contains(top, s) {
+						resultList = append(resultList, GetInfoData(m))
 						break
 					}
 				}
@@ -101,3 +104,60 @@ func GetCollectList(req *types.PrCollectListReq) (resultList []map[string]interf
 	}
 	return resultList[start:end], total
 }
+
+func GetInfoData(m map[string]interface{}) (result map[string]interface{}) {
+	result = make(map[string]interface{})
+	result["_id"] = encrypt.CommonEncodeArticle("content", common.ObjToString(m["_id"]))
+	result["title"] = m["title"]
+	result["toptype"] = m["toptype"]
+	result["subtype"] = m["subtype"]
+	result["publishtime"] = m["publishtime"]
+	if len(common.ObjToString(m["detail"])) > 200 {
+		result["detail"] = strings.ReplaceAll(common.ObjToString(m["detail"])[:200], " ", "")
+	} else {
+		result["detail"] = strings.ReplaceAll(common.ObjToString(m["detail"]), " ", "")
+	}
+	result["site"] = m["site"]
+	result["spidercode"] = m["spidercode"]
+	result["area"] = m["area"]
+	if m["city"] != nil {
+		result["city"] = m["city"]
+	}
+	if m["district"] != nil {
+		result["district"] = m["district"]
+	}
+	result["s_subscopeclass"] = m["s_subscopeclass"]
+	if m["budget"] != nil {
+		result["budget"] = m["budget"]
+	}
+	if m["buyerclass"] != nil {
+		result["buyerClass"] = m["buyerclass"]
+	}
+	if m["buyer"] != nil {
+		result["buyer"] = m["buyer"]
+		if m["buyertel"] != nil {
+			result["buyerTel"] = m["buyertel"]
+		}
+		if m["buyerperson"] != nil {
+			result["buyerPerson"] = m["buyerperson"]
+		}
+	}
+	if m["agency"] != nil {
+		result["agency"] = m["agency"]
+		if m["agencytel"] != nil {
+			result["agencyTel"] = m["agencytel"]
+		}
+		if m["agencyperson"] != nil {
+			result["agencyPerson"] = m["agencyperson"]
+		}
+	}
+	if m["bidopentime"] != nil {
+		result["bidOpenTime"] = m["bidopentime"]
+	}
+	if m["bidendtime"] != nil {
+		result["bidEndTime"] = m["bidendtime"]
+	}
+
+	return
+
+}