feat: 使用中的数据源不允许删除

This commit is contained in:
taojinlong 2021-06-03 16:25:36 +08:00
parent d2652dfd87
commit 9bcf6f49c9
5 changed files with 14 additions and 5 deletions

View File

@ -49,7 +49,7 @@ public class DatasourceController {
}
@PostMapping("/delete/{datasourceID}")
public void deleteDatasource(@PathVariable(value = "datasourceID") String datasourceID) {
public void deleteDatasource(@PathVariable(value = "datasourceID") String datasourceID) throws Exception {
datasourceService.deleteDatasource(datasourceID);
}

View File

@ -76,7 +76,13 @@ public class DatasourceService {
return extDataSourceMapper.query(gridExample);
}
public void deleteDatasource(String datasourceId) {
public void deleteDatasource(String datasourceId) throws Exception {
DatasetTableExample example = new DatasetTableExample();
example.createCriteria().andDataSourceIdEqualTo(datasourceId);
List<DatasetTable> datasetTables = datasetTableMapper.selectByExample(example);
if(CollectionUtils.isNotEmpty(datasetTables)){
throw new Exception(datasetTables.size() + Translator.get("i18n_datasource_not_allow_delete_msg"));
}
datasourceMapper.deleteByPrimaryKey(datasourceId);
}

View File

@ -246,3 +246,4 @@ i18n_sync_job_exists=There is already a synchronization task running, please try
i18n_datasource_check_fail=Invalid,please check config
i18n_not_find_user=Can not find user.
i18n_sql_not_empty=SQL can not be empty.
i18n_datasource_not_allow_delete_msg= datasets are using this data source and cannot be deleted

View File

@ -248,3 +248,4 @@ i18n_sync_job_exists=已经有同步任务在运行,稍后重试
i18n_datasource_check_fail=校验失败,请检查配置信息
i18n_not_find_user=未找到用户
i18n_sql_not_empty=SQL 不能为空
i18n_datasource_not_allow_delete_msg= 个数据集正在使用此数据源,无法删除

View File

@ -248,3 +248,4 @@ i18n_sync_job_exists=已經有同步任務在運行,稍後重試
i18n_datasource_check_fail=校驗失敗,請檢查配置信息
i18n_not_find_user=未找到用戶
i18n_sql_not_empty=SQL 不能為空
i18n_datasource_not_allow_delete_msg= 個數據集正在使用此數據源,無法刪除