From 58c9a2d8d548a0a67452c2d77c662b1b3b8e93bd Mon Sep 17 00:00:00 2001 From: fit2cloud-chenyw Date: Fri, 24 Dec 2021 17:30:43 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=B8=8B=E6=8B=89=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E9=80=89=E9=A1=B9=E9=87=8D=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dataset/DataSetTableFieldController.java | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/backend/src/main/java/io/dataease/controller/dataset/DataSetTableFieldController.java b/backend/src/main/java/io/dataease/controller/dataset/DataSetTableFieldController.java index 60dec0698a..897dbe3354 100644 --- a/backend/src/main/java/io/dataease/controller/dataset/DataSetTableFieldController.java +++ b/backend/src/main/java/io/dataease/controller/dataset/DataSetTableFieldController.java @@ -7,12 +7,15 @@ import io.dataease.service.dataset.DataSetFieldService; import io.dataease.service.dataset.DataSetTableFieldsService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; +import org.apache.commons.lang3.ObjectUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import java.util.ArrayList; +import java.util.Comparator; import java.util.List; +import java.util.TreeSet; import java.util.stream.Collectors; /** @@ -74,18 +77,27 @@ public class DataSetTableFieldController { @ApiOperation("值枚举") @PostMapping("fieldValues/{fieldId}") - public List fieldValues(@PathVariable String fieldId) throws Exception{ + public List fieldValues(@PathVariable String fieldId) throws Exception { return dataSetFieldService.fieldValues(fieldId); } @ApiOperation("多字段值枚举") @PostMapping("multFieldValues") - public List multFieldValues(@RequestBody List fieldIds) throws Exception{ + public List multFieldValues(@RequestBody List fieldIds) throws Exception { List results = new ArrayList<>(); for (String fieldId : fieldIds) { results.addAll(dataSetFieldService.fieldValues(fieldId)); } - results.stream().distinct().collect(Collectors.toList()); - return results; + ArrayList list = results.stream().collect( + Collectors.collectingAndThen( + Collectors.toCollection( + () -> new TreeSet<>(Comparator.comparing(t -> { + if (ObjectUtils.isEmpty(t)) return ""; + return t.toString(); + })) + ), ArrayList::new + ) + ); + return list; } }