Explorar o código

fix:数据导出筛选条件去重

duxin %!s(int64=2) %!d(string=hai) anos
pai
achega
53a5bb516f

+ 14 - 1
src/jfw/front/dataExport.go

@@ -159,7 +159,20 @@ func (d *DataExport) SieveData() {
 		winnerArr = strings.Split(winner, ",")
 		log.Println("winnerArr", winnerArr)
 	}
-	selectType = strings.Replace(selectType, "title,title", "title", -1)
+	if selectType != "" {
+		//去重 如果选取了标题及正文 引起的有2个title问题
+		if strings.Count(selectType, "title") > 1 {
+			var detail []string
+			for _, v := range strings.Split(selectType, ",") {
+				if v == "title" {
+					continue
+				}
+				detail = append(detail, v)
+			}
+			//维持原逻辑 正文表示标题及正文
+			selectType = strings.Replace(strings.Join(detail, ","), "detail", "title,detail", -1)
+		}
+	}
 	sieveCondition := map[string]interface{}{
 		"publishtime": publishtime,
 		"area":        areaArr,

+ 14 - 1
src/jfw/front/wx_dataExport.go

@@ -179,7 +179,20 @@ func (w *WxDataExport) SaveData() error {
 			log.Println("keyWord param 反序列化异常,查看前后台字段是否对应")
 		}
 	}
-	selectType = strings.Replace(selectType, "title,title", "title", -1)
+	if selectType != "" {
+		//去重 如果选取了标题及正文 引起的有2个title问题
+		if strings.Count(selectType, "title") > 1 {
+			var detail []string
+			for _, v := range strings.Split(selectType, ",") {
+				if v == "title" {
+					continue
+				}
+				detail = append(detail, v)
+			}
+			//维持原逻辑 正文表示标题及正文
+			selectType = strings.Replace(strings.Join(detail, ","), "detail", "title,detail", -1)
+		}
+	}
 	saveData := map[string]interface{}{
 		"publishtime": publishtime,
 		"area":        areaArr,

+ 14 - 1
src/jfw/modules/app/src/app/front/dataExport.go

@@ -184,7 +184,20 @@ func (w *WxDataExport) SaveData() error {
 			}
 		}
 	}
-	selectType = strings.Replace(selectType, "title,title", "title", -1)
+	if selectType != "" {
+		//去重 如果选取了标题及正文 引起的有2个title问题
+		if strings.Count(selectType, "title") > 1 {
+			var detail []string
+			for _, v := range strings.Split(selectType, ",") {
+				if v == "title" {
+					continue
+				}
+				detail = append(detail, v)
+			}
+			//维持原逻辑 正文表示标题及正文
+			selectType = strings.Replace(strings.Join(detail, ","), "detail", "title,detail", -1)
+		}
+	}
 	saveData := map[string]interface{}{
 		"publishtime": publishtime,
 		"area":        areaArr,