diff --git a/core/backend/src/main/java/io/dataease/controller/sys/SysPluginController.java b/core/backend/src/main/java/io/dataease/controller/sys/SysPluginController.java index 782953a328..a3f81c0aeb 100644 --- a/core/backend/src/main/java/io/dataease/controller/sys/SysPluginController.java +++ b/core/backend/src/main/java/io/dataease/controller/sys/SysPluginController.java @@ -58,7 +58,7 @@ public class SysPluginController { @RequiresPermissions("plugin:upload") public Map update(@PathVariable("pluginId") Long pluginId, @RequestParam("file") MultipartFile file) throws Exception { DeFileUtils.validateFile(file); - if (pluginService.uninstall(pluginId)) { + if (pluginService.uninstallForUpdate(pluginId, true)) { return pluginService.localInstall(file); } return null; diff --git a/core/backend/src/main/java/io/dataease/service/sys/PluginService.java b/core/backend/src/main/java/io/dataease/service/sys/PluginService.java index 9df89c03dc..f3589418d9 100644 --- a/core/backend/src/main/java/io/dataease/service/sys/PluginService.java +++ b/core/backend/src/main/java/io/dataease/service/sys/PluginService.java @@ -221,6 +221,10 @@ public class PluginService { * @return */ public Boolean uninstall(Long pluginId) { + return uninstallForUpdate(pluginId, false); + } + + public Boolean uninstallForUpdate(Long pluginId, boolean forUpdate) { MyPlugin myPlugin = myPluginMapper.selectByPrimaryKey(pluginId); if (ObjectUtils.isEmpty(myPlugin)) { String msg = "当前插件不存在"; @@ -232,7 +236,7 @@ public class PluginService { CacheUtils.removeAll(AuthConstants.USER_ROLE_CACHE_NAME); CacheUtils.removeAll(AuthConstants.USER_PERMISSION_CACHE_NAME); - if (myPlugin.getCategory().equalsIgnoreCase("datasource")) { + if (myPlugin.getCategory().equalsIgnoreCase("datasource") && !forUpdate) { if (CollectionUtils.isNotEmpty(datasourceService.selectByType(myPlugin.getDsType()))) { DEException.throwException(Translator.get("i18n_plugin_not_allow_delete")); }