forked from github/dataease
fix: tree搜索
This commit is contained in:
parent
e74846a8af
commit
57f131d86d
@ -117,6 +117,7 @@ public class ChartViewService {
|
||||
public List<ChartViewDTO> search(ChartViewRequest chartViewRequest) {
|
||||
String userId = String.valueOf(AuthUtils.getUser().getUserId());
|
||||
chartViewRequest.setUserId(userId);
|
||||
chartViewRequest.setSort("name asc");
|
||||
List<ChartViewDTO> ds = extChartViewMapper.search(chartViewRequest);
|
||||
if (CollectionUtils.isEmpty(ds)) {
|
||||
return ds;
|
||||
@ -129,6 +130,7 @@ public class ChartViewService {
|
||||
ids.add(ele.getPid());
|
||||
});
|
||||
|
||||
List<ChartViewDTO> 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<ChartViewDTO> res = new ArrayList<>();
|
||||
Map<String, ChartViewDTO> map = new TreeMap<>();
|
||||
group.forEach(ele -> map.put(ele.getId(), ele));
|
||||
Iterator<Map.Entry<String, ChartViewDTO>> 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) {
|
||||
|
@ -236,6 +236,7 @@ public class DataSetTableService {
|
||||
public List<DataSetTableDTO> search(DataSetTableRequest dataSetTableRequest) {
|
||||
String userId = String.valueOf(AuthUtils.getUser().getUserId());
|
||||
dataSetTableRequest.setUserId(userId);
|
||||
dataSetTableRequest.setSort("name asc");
|
||||
List<DataSetTableDTO> ds = extDataSetTableMapper.search(dataSetTableRequest);
|
||||
if (CollectionUtils.isEmpty(ds)) {
|
||||
return ds;
|
||||
@ -248,6 +249,7 @@ public class DataSetTableService {
|
||||
ids.add(ele.getPid());
|
||||
});
|
||||
|
||||
List<DataSetTableDTO> 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<DataSetTableDTO> res = new ArrayList<>();
|
||||
Map<String, DataSetTableDTO> map = new TreeMap<>();
|
||||
group.forEach(ele -> map.put(ele.getId(), ele));
|
||||
Iterator<Map.Entry<String, DataSetTableDTO>> 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) {
|
||||
|
Loading…
Reference in New Issue
Block a user