Skip to content

Commit 2c98b75

Browse files
xcsnx‘xcsnx’xcsnx
authored
[type:fix]fix delete namespace (apache#5964)
* fix * fix * fix * fix cr --------- Co-authored-by: ‘xcsnx’ <‘[email protected]’> Co-authored-by: xcsnx <[email protected]>
1 parent 3557781 commit 2c98b75

File tree

2 files changed

+8
-13
lines changed

2 files changed

+8
-13
lines changed

shenyu-admin/src/main/java/org/apache/shenyu/admin/model/entity/PluginDO.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ public static PluginDO buildPluginDO(final NamespacePluginVO namespacePluginVO)
245245
pluginDO.setId(UUIDUtils.getInstance().generateShortUuid());
246246
pluginDO.setDateCreated(currentTime);
247247
} else {
248-
pluginDO.setId(item.getId());
248+
pluginDO.setId(item.getPluginId());
249249
}
250250
if (Objects.nonNull(item.getFile())) {
251251
pluginDO.setPluginJar(Base64.decode(item.getFile()));

shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/NamespaceServiceImpl.java

+7-12
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,16 @@
2121
import org.apache.commons.collections4.CollectionUtils;
2222
import org.apache.commons.lang3.StringUtils;
2323
import org.apache.shenyu.admin.exception.ShenyuAdminException;
24+
import org.apache.shenyu.admin.mapper.AppAuthMapper;
2425
import org.apache.shenyu.admin.mapper.AuthPathMapper;
2526
import org.apache.shenyu.admin.mapper.DiscoveryMapper;
2627
import org.apache.shenyu.admin.mapper.MetaDataMapper;
2728
import org.apache.shenyu.admin.mapper.NamespaceMapper;
28-
import org.apache.shenyu.admin.mapper.AppAuthMapper;
2929
import org.apache.shenyu.admin.mapper.NamespacePluginRelMapper;
3030
import org.apache.shenyu.admin.mapper.RuleMapper;
3131
import org.apache.shenyu.admin.mapper.SelectorMapper;
3232
import org.apache.shenyu.admin.model.dto.NamespaceDTO;
3333
import org.apache.shenyu.admin.model.entity.AppAuthDO;
34-
import org.apache.shenyu.admin.model.entity.DiscoveryDO;
3534
import org.apache.shenyu.admin.model.entity.MetaDataDO;
3635
import org.apache.shenyu.admin.model.entity.NamespaceDO;
3736
import org.apache.shenyu.admin.model.entity.RuleDO;
@@ -141,17 +140,17 @@ public String delete(final List<String> ids) {
141140
if (CollectionUtils.isEmpty(namespaceIdList)) {
142141
throw new ShenyuAdminException(AdminConstants.SYS_NAMESPACE_ID_NOT_EXIST);
143142
}
144-
List<NamespacePluginVO> namespacePluginVOS = namespacePluginRelMapper.selectAllByNamespaceIds(namespaceIdList);
145-
if (CollectionUtils.isNotEmpty(namespacePluginVOS)) {
146-
throw new ShenyuAdminException("Plugins exist under those namespace!");
143+
List<RuleDO> ruleDOList = ruleMapper.selectAllByNamespaceIds(namespaceIdList);
144+
if (CollectionUtils.isNotEmpty(ruleDOList)) {
145+
throw new ShenyuAdminException("rule exist under those namespace!");
147146
}
148147
List<SelectorDO> selectorDOS = selectorMapper.selectAllByNamespaceIds(namespaceIdList);
149148
if (CollectionUtils.isNotEmpty(selectorDOS)) {
150149
throw new ShenyuAdminException("selector exist under those namespace!");
151150
}
152-
List<RuleDO> ruleDOList = ruleMapper.selectAllByNamespaceIds(namespaceIdList);
153-
if (CollectionUtils.isNotEmpty(ruleDOList)) {
154-
throw new ShenyuAdminException("rule exist under those namespace!");
151+
List<NamespacePluginVO> namespacePluginVOS = namespacePluginRelMapper.selectAllByNamespaceIds(namespaceIdList);
152+
if (CollectionUtils.isNotEmpty(namespacePluginVOS)) {
153+
throw new ShenyuAdminException("Plugins exist under those namespace!");
155154
}
156155
List<MetaDataDO> metaDataDOList = metaDataMapper.findAllByNamespaceIds(namespaceIdList);
157156
if (CollectionUtils.isNotEmpty(metaDataDOList)) {
@@ -161,10 +160,6 @@ public String delete(final List<String> ids) {
161160
if (CollectionUtils.isNotEmpty(appPathDOList)) {
162161
throw new ShenyuAdminException("appPath exist under those namespace!");
163162
}
164-
List<DiscoveryDO> discoveryDOList = discoveryMapper.selectAllByNamespaceIds(namespaceIdList);
165-
if (CollectionUtils.isNotEmpty(discoveryDOList)) {
166-
throw new ShenyuAdminException("discovery exist under those namespace!");
167-
}
168163
namespaceMapper.deleteByIds(ids);
169164
return ShenyuResultMessage.DELETE_SUCCESS;
170165
}

0 commit comments

Comments
 (0)