fix: 數據源插件卸载

This commit is contained in:
taojinlong 2022-04-29 17:51:17 +08:00
parent 24ae00582f
commit bcb4084e69
5 changed files with 25 additions and 0 deletions

View File

@ -330,6 +330,12 @@ public class DatasourceService {
return datasourceMapper.selectByPrimaryKey(id);
}
public List<Datasource> selectByType(String type){
DatasourceExample datasourceExample = new DatasourceExample();
datasourceExample.createCriteria().andTypeEqualTo(type);
return datasourceMapper.selectByExampleWithBLOBs(datasourceExample);
}
public void initAllDataSourceConnectionPool() {
List<Datasource> datasources = datasourceMapper.selectByExampleWithBLOBs(new DatasourceExample());
datasources.forEach(datasource -> {

View File

@ -13,10 +13,14 @@ import io.dataease.commons.utils.DeFileUtils;
import io.dataease.commons.utils.LogUtil;
import io.dataease.commons.utils.ZipUtils;
import io.dataease.controller.sys.base.BaseGridRequest;
import io.dataease.i18n.Translator;
import io.dataease.listener.util.CacheUtils;
import io.dataease.plugins.common.base.domain.MyPlugin;
import io.dataease.plugins.common.base.mapper.MyPluginMapper;
import io.dataease.plugins.config.LoadjarUtil;
import io.dataease.plugins.config.SpringContextUtil;
import io.dataease.service.datasource.DatasourceService;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
@ -49,6 +53,9 @@ public class PluginService {
@Resource
private MyPluginMapper myPluginMapper;
@Resource
private DatasourceService datasourceService;
@Autowired
private LoadjarUtil loadjarUtil;
@ -187,6 +194,15 @@ public class PluginService {
CacheUtils.removeAll(AuthConstants.USER_CACHE_NAME);
CacheUtils.removeAll(AuthConstants.USER_ROLE_CACHE_NAME);
CacheUtils.removeAll(AuthConstants.USER_PERMISSION_CACHE_NAME);
if(myPlugin.getCategory().equalsIgnoreCase("datasource")){
if(CollectionUtils.isNotEmpty(datasourceService.selectByType(myPlugin.getDsType()))){
throw new RuntimeException(Translator.get("i18n_plugin_not_allow_delete"));
}
SpringContextUtil.getBeanFactory().removeBeanDefinition(myPlugin.getDsType() + "DsProvider");
SpringContextUtil.getBeanFactory().removeBeanDefinition(myPlugin.getDsType() + "QueryProvider");
SpringContextUtil.getBeanFactory().removeBeanDefinition(myPlugin.getDsType() + "Service");
}
myPluginMapper.deleteByPrimaryKey(pluginId);
return true;
}

View File

@ -123,3 +123,4 @@ theme_name_empty=name can not be empty
i18n_public_chart=【Public Chart】
i18n_class_blue=Blue Tone
插件管理=Plugins
i18n_plugin_not_allow_delete=The plugin in in use cannot be deleted

View File

@ -122,4 +122,5 @@ theme_name_empty=名称不能为空
i18n_public_chart=【存量视图】
i18n_class_blue=蓝色调
插件管理=插件管理
i18n_plugin_not_allow_delete=正在使用的插件不允许删除

View File

@ -123,3 +123,4 @@ theme_name_empty=名稱不能為空
i18n_public_chart=【存量视图】
i18n_class_blue=蓝色调
插件管理=插件管理
i18n_plugin_not_allow_delete=正在使用的插件不允許刪除