From 57f131d86d127ce4a7c9855eb865d24e59e3718e Mon Sep 17 00:00:00 2001 From: junjie Date: Sat, 31 Jul 2021 16:55:34 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20tree=E6=90=9C=E7=B4=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dataease/service/chart/ChartViewService.java | 16 ++++++++++++++-- .../service/dataset/DataSetTableService.java | 16 ++++++++++++++-- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/backend/src/main/java/io/dataease/service/chart/ChartViewService.java b/backend/src/main/java/io/dataease/service/chart/ChartViewService.java index 85bf03df55..5edfc6160d 100644 --- a/backend/src/main/java/io/dataease/service/chart/ChartViewService.java +++ b/backend/src/main/java/io/dataease/service/chart/ChartViewService.java @@ -117,6 +117,7 @@ public class ChartViewService { public List search(ChartViewRequest chartViewRequest) { String userId = String.valueOf(AuthUtils.getUser().getUserId()); chartViewRequest.setUserId(userId); + chartViewRequest.setSort("name asc"); List ds = extChartViewMapper.search(chartViewRequest); if (CollectionUtils.isEmpty(ds)) { return ds; @@ -129,6 +130,7 @@ public class ChartViewService { ids.add(ele.getPid()); }); + List group = new ArrayList<>(); ChartGroupRequest chartGroupRequest = new ChartGroupRequest(); chartGroupRequest.setUserId(userId); chartGroupRequest.setIds(ids); @@ -140,13 +142,23 @@ public class ChartViewService { BeanUtils.copyBean(dto, ele); dto.setIsLeaf(false); dto.setType("group"); - ds.add(dto); + group.add(dto); ids.add(ele.getPid()); }); chartGroupRequest.setIds(ids); search = extChartGroupMapper.search(chartGroupRequest); } - return ds; + + List res = new ArrayList<>(); + Map map = new TreeMap<>(); + group.forEach(ele -> map.put(ele.getId(), ele)); + Iterator> iterator = map.entrySet().iterator(); + while (iterator.hasNext()) { + res.add(iterator.next().getValue()); + } + res.sort(Comparator.comparing(ChartViewDTO::getName)); + res.addAll(ds); + return res; } public ChartViewWithBLOBs get(String id) { diff --git a/backend/src/main/java/io/dataease/service/dataset/DataSetTableService.java b/backend/src/main/java/io/dataease/service/dataset/DataSetTableService.java index 5c61f458e0..cb1f05a3f2 100644 --- a/backend/src/main/java/io/dataease/service/dataset/DataSetTableService.java +++ b/backend/src/main/java/io/dataease/service/dataset/DataSetTableService.java @@ -236,6 +236,7 @@ public class DataSetTableService { public List search(DataSetTableRequest dataSetTableRequest) { String userId = String.valueOf(AuthUtils.getUser().getUserId()); dataSetTableRequest.setUserId(userId); + dataSetTableRequest.setSort("name asc"); List ds = extDataSetTableMapper.search(dataSetTableRequest); if (CollectionUtils.isEmpty(ds)) { return ds; @@ -248,6 +249,7 @@ public class DataSetTableService { ids.add(ele.getPid()); }); + List group = new ArrayList<>(); DataSetGroupRequest dataSetGroupRequest = new DataSetGroupRequest(); dataSetGroupRequest.setUserId(userId); dataSetGroupRequest.setIds(ids); @@ -259,13 +261,23 @@ public class DataSetTableService { BeanUtils.copyBean(dto, ele); dto.setIsLeaf(false); dto.setType("group"); - ds.add(dto); + group.add(dto); ids.add(ele.getPid()); }); dataSetGroupRequest.setIds(ids); search = extDataSetGroupMapper.search(dataSetGroupRequest); } - return ds; + + List res = new ArrayList<>(); + Map map = new TreeMap<>(); + group.forEach(ele -> map.put(ele.getId(), ele)); + Iterator> iterator = map.entrySet().iterator(); + while (iterator.hasNext()) { + res.add(iterator.next().getValue()); + } + res.sort(Comparator.comparing(DatasetTable::getName)); + res.addAll(ds); + return res; } public DatasetTable get(String id) {