This is an automated email from the ASF dual-hosted git repository.

liuhongyu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shenyu.git


The following commit(s) were added to refs/heads/master by this push:
     new 2c98b75bf0 [type:fix]fix delete namespace  (#5964)
2c98b75bf0 is described below

commit 2c98b75bf0155e899d7700162ba0ff3d36c1a708
Author: xcsnx <[email protected]>
AuthorDate: Thu Mar 20 16:15:07 2025 +0800

    [type:fix]fix delete namespace  (#5964)
    
    * fix
    
    * fix
    
    * fix
    
    * fix cr
    
    ---------
    
    Co-authored-by: ‘xcsnx’ <‘[email protected]’>
    Co-authored-by: xcsnx <[email protected]>
---
 .../apache/shenyu/admin/model/entity/PluginDO.java    |  2 +-
 .../admin/service/impl/NamespaceServiceImpl.java      | 19 +++++++------------
 2 files changed, 8 insertions(+), 13 deletions(-)

diff --git 
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/entity/PluginDO.java 
b/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/entity/PluginDO.java
index 30ed56b4ba..fda4a8e8d7 100644
--- 
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/entity/PluginDO.java
+++ 
b/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/entity/PluginDO.java
@@ -245,7 +245,7 @@ public final class PluginDO extends BaseDO {
                 pluginDO.setId(UUIDUtils.getInstance().generateShortUuid());
                 pluginDO.setDateCreated(currentTime);
             } else {
-                pluginDO.setId(item.getId());
+                pluginDO.setId(item.getPluginId());
             }
             if (Objects.nonNull(item.getFile())) {
                 pluginDO.setPluginJar(Base64.decode(item.getFile()));
diff --git 
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/NamespaceServiceImpl.java
 
b/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/NamespaceServiceImpl.java
index 309e491638..500d1e0212 100644
--- 
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/NamespaceServiceImpl.java
+++ 
b/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/NamespaceServiceImpl.java
@@ -21,17 +21,16 @@ import com.google.common.collect.Lists;
 import org.apache.commons.collections4.CollectionUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.shenyu.admin.exception.ShenyuAdminException;
+import org.apache.shenyu.admin.mapper.AppAuthMapper;
 import org.apache.shenyu.admin.mapper.AuthPathMapper;
 import org.apache.shenyu.admin.mapper.DiscoveryMapper;
 import org.apache.shenyu.admin.mapper.MetaDataMapper;
 import org.apache.shenyu.admin.mapper.NamespaceMapper;
-import org.apache.shenyu.admin.mapper.AppAuthMapper;
 import org.apache.shenyu.admin.mapper.NamespacePluginRelMapper;
 import org.apache.shenyu.admin.mapper.RuleMapper;
 import org.apache.shenyu.admin.mapper.SelectorMapper;
 import org.apache.shenyu.admin.model.dto.NamespaceDTO;
 import org.apache.shenyu.admin.model.entity.AppAuthDO;
-import org.apache.shenyu.admin.model.entity.DiscoveryDO;
 import org.apache.shenyu.admin.model.entity.MetaDataDO;
 import org.apache.shenyu.admin.model.entity.NamespaceDO;
 import org.apache.shenyu.admin.model.entity.RuleDO;
@@ -141,17 +140,17 @@ public class NamespaceServiceImpl implements 
NamespaceService {
         if (CollectionUtils.isEmpty(namespaceIdList)) {
             throw new 
ShenyuAdminException(AdminConstants.SYS_NAMESPACE_ID_NOT_EXIST);
         }
-        List<NamespacePluginVO> namespacePluginVOS = 
namespacePluginRelMapper.selectAllByNamespaceIds(namespaceIdList);
-        if (CollectionUtils.isNotEmpty(namespacePluginVOS)) {
-            throw new ShenyuAdminException("Plugins exist under those 
namespace!");
+        List<RuleDO> ruleDOList = 
ruleMapper.selectAllByNamespaceIds(namespaceIdList);
+        if (CollectionUtils.isNotEmpty(ruleDOList)) {
+            throw new ShenyuAdminException("rule exist under those 
namespace!");
         }
         List<SelectorDO> selectorDOS = 
selectorMapper.selectAllByNamespaceIds(namespaceIdList);
         if (CollectionUtils.isNotEmpty(selectorDOS)) {
             throw new ShenyuAdminException("selector exist under those 
namespace!");
         }
-        List<RuleDO> ruleDOList = 
ruleMapper.selectAllByNamespaceIds(namespaceIdList);
-        if (CollectionUtils.isNotEmpty(ruleDOList)) {
-            throw new ShenyuAdminException("rule exist under those 
namespace!");
+        List<NamespacePluginVO> namespacePluginVOS = 
namespacePluginRelMapper.selectAllByNamespaceIds(namespaceIdList);
+        if (CollectionUtils.isNotEmpty(namespacePluginVOS)) {
+            throw new ShenyuAdminException("Plugins exist under those 
namespace!");
         }
         List<MetaDataDO> metaDataDOList = 
metaDataMapper.findAllByNamespaceIds(namespaceIdList);
         if (CollectionUtils.isNotEmpty(metaDataDOList)) {
@@ -161,10 +160,6 @@ public class NamespaceServiceImpl implements 
NamespaceService {
         if (CollectionUtils.isNotEmpty(appPathDOList)) {
             throw new ShenyuAdminException("appPath exist under those 
namespace!");
         }
-        List<DiscoveryDO> discoveryDOList = 
discoveryMapper.selectAllByNamespaceIds(namespaceIdList);
-        if (CollectionUtils.isNotEmpty(discoveryDOList)) {
-            throw new ShenyuAdminException("discovery exist under those 
namespace!");
-        }
         namespaceMapper.deleteByIds(ids);
         return ShenyuResultMessage.DELETE_SUCCESS;
     }

Reply via email to