forked from github/dataease
refactor: 优化数据源删除提示信息
This commit is contained in:
parent
c9b355c69e
commit
7add22f6d8
@ -74,8 +74,8 @@ public class DatasourceController {
|
||||
@DePermission(type = DePermissionType.DATASOURCE, level = ResourceAuthLevel.DATASOURCE_LEVEL_MANAGE)
|
||||
@ApiOperation("删除数据源")
|
||||
@PostMapping("/delete/{datasourceID}")
|
||||
public void deleteDatasource(@PathVariable(value = "datasourceID") String datasourceID) throws Exception {
|
||||
datasourceService.deleteDatasource(datasourceID);
|
||||
public ResultHolder deleteDatasource(@PathVariable(value = "datasourceID") String datasourceID) throws Exception {
|
||||
return datasourceService.deleteDatasource(datasourceID);
|
||||
}
|
||||
|
||||
@RequiresPermissions("datasource:read")
|
||||
|
@ -163,16 +163,17 @@ public class DatasourceService {
|
||||
}
|
||||
|
||||
@DeCleaner(DePermissionType.DATASOURCE)
|
||||
public void deleteDatasource(String datasourceId) throws Exception {
|
||||
public ResultHolder deleteDatasource(String datasourceId) throws Exception {
|
||||
DatasetTableExample example = new DatasetTableExample();
|
||||
example.createCriteria().andDataSourceIdEqualTo(datasourceId);
|
||||
List<DatasetTable> datasetTables = datasetTableMapper.selectByExample(example);
|
||||
if(CollectionUtils.isNotEmpty(datasetTables)){
|
||||
DataEaseException.throwException(datasetTables.size() + Translator.get("i18n_datasource_not_allow_delete_msg"));
|
||||
return ResultHolder.error(datasetTables.size() + Translator.get("i18n_datasource_not_allow_delete_msg"));
|
||||
}
|
||||
Datasource datasource = datasourceMapper.selectByPrimaryKey(datasourceId);
|
||||
datasourceMapper.deleteByPrimaryKey(datasourceId);
|
||||
handleConnectionPool(datasource, "delete");
|
||||
return ResultHolder.success("success");
|
||||
}
|
||||
|
||||
public void updateDatasource(Datasource datasource) {
|
||||
|
@ -268,9 +268,16 @@ export default {
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
delDs(datasource.id).then(res => {
|
||||
this.$success(this.$t('commons.delete_success'))
|
||||
this.switchMain('DataHome', {}, this.tData)
|
||||
this.refreshType(datasource)
|
||||
if(res.success){
|
||||
this.$success(this.$t('commons.delete_success'))
|
||||
this.switchMain('DataHome', {}, this.tData)
|
||||
this.refreshType(datasource)
|
||||
}else {
|
||||
this.$message({
|
||||
type: 'error',
|
||||
message: res.message
|
||||
})
|
||||
}
|
||||
})
|
||||
}).catch(() => {
|
||||
this.$message({
|
||||
|
Loading…
Reference in New Issue
Block a user