From e25ffdfb8458228f7d0ab9b4d0aeb1cc54dd02db Mon Sep 17 00:00:00 2001 From: Yueng <14617246+YuengMeYuuer@user.noreply.gitee.com> Date: Tue, 10 Sep 2024 16:33:29 +0800 Subject: [PATCH] =?UTF-8?q?fix:()=20=E4=BC=98=E5=8C=96=E4=BB=BB=E5=8A=A1?= =?UTF-8?q?=E8=B0=83=E5=8A=A8=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/DataRunNameServiceImpl.java | 37 +++++++++++-------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/cloud-property-server/src/main/java/com/muyu/server/service/impl/DataRunNameServiceImpl.java b/cloud-property-server/src/main/java/com/muyu/server/service/impl/DataRunNameServiceImpl.java index 5f658c5..19601ce 100644 --- a/cloud-property-server/src/main/java/com/muyu/server/service/impl/DataRunNameServiceImpl.java +++ b/cloud-property-server/src/main/java/com/muyu/server/service/impl/DataRunNameServiceImpl.java @@ -116,7 +116,7 @@ public class DataRunNameServiceImpl implements DataRunNameService { //数据库名称查询 List dataNameList = dataNameService.list().stream() .map(DataName::dataNameBuild).toList(); - HashSet set1 = new HashSet<>(); + HashSet set1 = new HashSet<>(); //遍历获取数据数据库名称对象 dataNameList.forEach(dataName -> { @@ -142,24 +142,32 @@ public class DataRunNameServiceImpl implements DataRunNameService { //在取数据数据遍历里获取表名称查询方法 tableIdAndBasicIdByUserId.forEach(tableIdAndBasicId -> { - DataName dataName1 = this.dataDeptShow(tableIdAndBasicId, dataName); - System.out.println(dataName1); - set1.add(dataName1); + List dataName1 = this.dataDeptShow(tableIdAndBasicId, dataName); + if (CollectionUtils.isEmpty(dataName1)){ + return; + } + dataName1.forEach(tableNames -> { + set1.add(tableNames); + }); + }); idByDeptId.forEach(tableIdAndBasicId -> { - DataName dataName1 = this.dataDeptShow(tableIdAndBasicId, dataName); - System.out.println(dataName1); - set1.add(dataName1); + List dataName1 = this.dataDeptShow(tableIdAndBasicId, dataName); + if (CollectionUtils.isEmpty(dataName1)){ + return; + } + dataName1.forEach(tableNames -> { + set1.add(tableNames); + }); }); -// dataName.setTableNames(set2); + dataName.setTableNames((List) set1); }); - List list = new ArrayList<>(set1); //返回所有数据 - return list; + return dataNameList; } - private DataName dataDeptShow(AssetAuthorization tableIdAndBasicId, DataName dataName) { + private List dataDeptShow(AssetAuthorization tableIdAndBasicId, DataName dataName) { List tableNamesList = tableRunNameService.list(new LambdaQueryWrapper() .eq(TableNames::getDataId, dataName.getId()) .eq(TableNames::getId, tableIdAndBasicId.getTableId())) @@ -173,19 +181,16 @@ public class DataRunNameServiceImpl implements DataRunNameService { return null; } - //在每一次循环中创建一个新的集合 - ArrayList namesArrayList = new ArrayList<>(tableNamesList); //添加到数据库实体类集合字段上 - dataName.setTableNames(namesArrayList); //将添加好的实体类集合进行遍历操作 log.info("数据库表名称:{}",dataName.getTableNames()); if (CollectionUtils.isEmpty(dataName.getTableNames())) {return null;} //在内部封装方法 - dataName.getTableNames().forEach(tableName1 -> { + tableNamesList.forEach(tableName1 -> { List tableFies = this.tableStructureShow(tableName1); tableName1.setTableFie(tableFies); }); - return dataName; + return tableNamesList; } /**