diff --git a/backend/src/main/java/io/dataease/controller/dataset/DataSetTableController.java b/backend/src/main/java/io/dataease/controller/dataset/DataSetTableController.java index aca169acb0..8c36e7f45b 100644 --- a/backend/src/main/java/io/dataease/controller/dataset/DataSetTableController.java +++ b/backend/src/main/java/io/dataease/controller/dataset/DataSetTableController.java @@ -23,6 +23,7 @@ import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import javax.annotation.Resource; +import java.util.Collections; import java.util.List; import java.util.Map; @@ -44,8 +45,8 @@ public class DataSetTableController { }, logical = Logical.AND) @ApiOperation("批量保存") @PostMapping("batchAdd") - public void batchAdd(@RequestBody List datasetTable) throws Exception { - dataSetTableService.batchInsert(datasetTable); + public List batchAdd(@RequestBody List datasetTable) throws Exception { + return dataSetTableService.batchInsert(datasetTable); } @DePermissions(value = { @@ -55,11 +56,11 @@ public class DataSetTableController { }, logical = Logical.AND) @ApiOperation("更新") @PostMapping("update") - public void save(@RequestBody DataSetTableRequest datasetTable) throws Exception { + public List save(@RequestBody DataSetTableRequest datasetTable) throws Exception { if (datasetTable.getType().equalsIgnoreCase("excel")) { - dataSetTableService.saveExcel(datasetTable); + return dataSetTableService.saveExcel(datasetTable); } else { - dataSetTableService.save(datasetTable); + return Collections.singletonList(dataSetTableService.save(datasetTable)); } } 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 7835eada20..d97a57efdf 100644 --- a/backend/src/main/java/io/dataease/service/dataset/DataSetTableService.java +++ b/backend/src/main/java/io/dataease/service/dataset/DataSetTableService.java @@ -145,16 +145,18 @@ public class DataSetTableService { private static Logger logger = LoggerFactory.getLogger(ClassloaderResponsity.class); @DeCleaner(value = DePermissionType.DATASET, key = "sceneId") - public void batchInsert(List datasetTable) throws Exception { + public List batchInsert(List datasetTable) throws Exception { // 保存之前校验table名称 checkNames(datasetTable); + List list = new ArrayList<>(); for (DataSetTableRequest table : datasetTable) { - save(table); + list.add(save(table)); // 清理权限缓存 CacheUtils.removeAll(AuthConstants.USER_DATASET_NAME); CacheUtils.removeAll(AuthConstants.ROLE_DATASET_NAME); CacheUtils.removeAll(AuthConstants.DEPT_DATASET_NAME); } + return list; } private void extractData(DataSetTableRequest datasetTable) throws Exception { @@ -176,10 +178,11 @@ public class DataSetTableService { @Transactional(propagation = Propagation.NOT_SUPPORTED) @DeCleaner(value = DePermissionType.DATASET, key = "sceneId") - public void saveExcel(DataSetTableRequest datasetTable) throws Exception { + public List saveExcel(DataSetTableRequest datasetTable) throws Exception { List datasetIdList = new ArrayList<>(); if (StringUtils.isEmpty(datasetTable.getId())) { + List list = new ArrayList<>(); if (datasetTable.isMergeSheet()) { Map> map = datasetTable.getSheets().stream() .collect(Collectors.groupingBy(ExcelSheetData::getFieldsMd5)); @@ -208,6 +211,7 @@ public class DataSetTableService { sysAuthService.copyAuth(sheetTable.getId(), SysAuthConstants.AUTH_SOURCE_TYPE_DATASET); saveExcelTableField(sheetTable.getId(), excelSheetDataList.get(0).getFields(), true); datasetIdList.add(sheetTable.getId()); + list.add(sheetTable); DeLogUtils.save(SysLogConstants.OPERATE_TYPE.CREATE, SysLogConstants.SOURCE_TYPE.DATASET, datasetTable.getId(), datasetTable.getSceneId(), null, null); } datasetIdList.forEach(datasetId -> { @@ -239,16 +243,16 @@ public class DataSetTableService { sysAuthService.copyAuth(sheetTable.getId(), SysAuthConstants.AUTH_SOURCE_TYPE_DATASET); saveExcelTableField(sheetTable.getId(), sheet.getFields(), true); datasetIdList.add(sheetTable.getId()); + list.add(sheetTable); DeLogUtils.save(SysLogConstants.OPERATE_TYPE.MODIFY, SysLogConstants.SOURCE_TYPE.DATASET, datasetTable.getId(), datasetTable.getSceneId(), null, null); } datasetIdList.forEach(datasetId -> { commonThreadPool.addTask(() -> extractDataService.extractExcelData(datasetId, "all_scope", "初始导入", null, datasetIdList)); }); - - } - return; + + return list; } List excelSheetDataList = new ArrayList<>(); @@ -287,6 +291,7 @@ public class DataSetTableService { null, Arrays.asList(datasetTable.getId()))); } DeLogUtils.save(SysLogConstants.OPERATE_TYPE.MODIFY, SysLogConstants.SOURCE_TYPE.DATASET, datasetTable.getId(), datasetTable.getSceneId(), null, null); + return Collections.singletonList(datasetTable); } @DeCleaner(value = DePermissionType.DATASET, key = "sceneId")