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 7c682cf9c9 [type:fix] fix namespace plugin generate (#5757)
7c682cf9c9 is described below
commit 7c682cf9c9bf0fd5c4ff98337d001a8486dd154a
Author: moremind <[email protected]>
AuthorDate: Tue Nov 5 23:38:53 2024 +0800
[type:fix] fix namespace plugin generate (#5757)
* [type:fix] fix namespace plugin generate
* [type:fix] fix namespace plugin generate
---
.../admin/config/HttpLongPollingSyncConfiguration.java | 2 ++
.../apache/shenyu/admin/controller/ConfigController.java | 2 ++
.../shenyu/admin/controller/NamespacePluginController.java | 2 +-
.../admin/service/impl/NamespacePluginServiceImpl.java | 2 +-
.../shenyu/admin/service/impl/NamespaceServiceImpl.java | 14 --------------
.../main/resources/mappers/namespace-plugin-rel-sqlmap.xml | 3 +--
6 files changed, 7 insertions(+), 18 deletions(-)
diff --git
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/config/HttpLongPollingSyncConfiguration.java
b/shenyu-admin/src/main/java/org/apache/shenyu/admin/config/HttpLongPollingSyncConfiguration.java
index 0b06a529e0..3535d8602c 100644
---
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/config/HttpLongPollingSyncConfiguration.java
+++
b/shenyu-admin/src/main/java/org/apache/shenyu/admin/config/HttpLongPollingSyncConfiguration.java
@@ -20,6 +20,7 @@ package org.apache.shenyu.admin.config;
import org.apache.shenyu.admin.config.properties.HttpSyncProperties;
import
org.apache.shenyu.admin.listener.http.HttpLongPollingDataChangedListener;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import
org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@@ -29,6 +30,7 @@ import org.springframework.context.annotation.Configuration;
*/
@Configuration
@EnableConfigurationProperties(HttpSyncProperties.class)
+@ConditionalOnProperty(name = "shenyu.sync.http.enabled", havingValue = "true")
public class HttpLongPollingSyncConfiguration {
/**
diff --git
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/ConfigController.java
b/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/ConfigController.java
index a01c1819de..9c43d0df90 100644
---
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/ConfigController.java
+++
b/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/ConfigController.java
@@ -31,6 +31,7 @@ import org.apache.shenyu.admin.service.NamespaceService;
import org.apache.shenyu.admin.utils.ShenyuResultMessage;
import org.apache.shenyu.common.dto.ConfigData;
import org.apache.shenyu.common.enums.ConfigGroupEnum;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
@@ -45,6 +46,7 @@ import java.util.Map;
@ResponseBody
@RequestMapping("/configs")
@RestController
+@ConditionalOnBean(HttpLongPollingDataChangedListener.class)
public class ConfigController {
private final HttpLongPollingDataChangedListener longPollingListener;
diff --git
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/NamespacePluginController.java
b/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/NamespacePluginController.java
index f77dda1b10..c28c65b1f7 100644
---
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/NamespacePluginController.java
+++
b/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/NamespacePluginController.java
@@ -141,7 +141,7 @@ public class NamespacePluginController implements
PagedController<NamespacePlugi
*/
@PutMapping("/{namespaceId}/{pluginId}")
@RequiresPermissions("system:plugin:edit")
- public ShenyuAdminResult addPlugin(@Existed(message = "namespace is not
exist", provider = NamespaceMapper.class)
+ public ShenyuAdminResult generateNamespacePlugin(@Existed(message =
"namespace is not exist", provider = NamespaceMapper.class)
@PathVariable("namespaceId") final
String namespaceId,
@Existed(message = "plugin is not
exist", provider = PluginMapper.class)
@PathVariable("pluginId") final String
pluginId) {
diff --git
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/NamespacePluginServiceImpl.java
b/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/NamespacePluginServiceImpl.java
index 5470449cf2..4aca654f50 100644
---
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/NamespacePluginServiceImpl.java
+++
b/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/NamespacePluginServiceImpl.java
@@ -80,7 +80,7 @@ public class NamespacePluginServiceImpl implements
NamespacePluginService {
@Override
public NamespacePluginVO create(final String namespaceId, final String
pluginId) {
NamespacePluginVO existNamespacePluginVO =
namespacePluginRelMapper.selectByPluginIdAndNamespaceId(pluginId, namespaceId);
- if (!Objects.isNull(existNamespacePluginVO)) {
+ if (Objects.nonNull(existNamespacePluginVO)) {
throw new
ShenyuAdminException(AdminConstants.NAMESPACE_PLUGIN_EXIST);
}
PluginDO pluginDO = pluginMapper.selectById(pluginId);
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 b5ce42fa81..b1741b91a0 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
@@ -24,7 +24,6 @@ import org.apache.shenyu.admin.mapper.NamespaceMapper;
import org.apache.shenyu.admin.mapper.NamespacePluginRelMapper;
import org.apache.shenyu.admin.model.dto.NamespaceDTO;
import org.apache.shenyu.admin.model.entity.NamespaceDO;
-import org.apache.shenyu.admin.model.entity.NamespacePluginRelDO;
import org.apache.shenyu.admin.model.page.CommonPager;
import org.apache.shenyu.admin.model.page.PageResultUtils;
import org.apache.shenyu.admin.model.query.NamespaceQuery;
@@ -35,7 +34,6 @@ import org.apache.shenyu.admin.transfer.NamespaceTransfer;
import org.apache.shenyu.admin.utils.ShenyuResultMessage;
import org.apache.shenyu.common.constant.AdminConstants;
import org.apache.shenyu.common.constant.Constants;
-import org.apache.shenyu.common.dto.PluginData;
import org.apache.shenyu.common.utils.NamespaceIDUtils;
import org.apache.shenyu.common.utils.UUIDUtils;
import org.springframework.stereotype.Service;
@@ -126,19 +124,7 @@ public class NamespaceServiceImpl implements
NamespaceService {
.dateCreated(currentTime)
.dateUpdated(currentTime)
.build();
- List<PluginData> pluginData = pluginService.listAll();
- List<NamespacePluginRelDO> pluginNsRelList = pluginData.stream().map(s
-> NamespacePluginRelDO.builder()
- .id(UUIDUtils.getInstance().generateShortUuid())
- .pluginId(s.getId())
- .config(s.getConfig())
- .sort(s.getSort())
- .enabled(s.getEnabled())
- .namespaceId(namespaceId)
- .dateCreated(currentTime)
- .dateUpdated(currentTime)
- .build()).collect(Collectors.toList());
namespaceMapper.insert(namespaceDO);
- namespacePluginRelMapper.batchSave(pluginNsRelList);
return NamespaceTransfer.INSTANCE.mapToVo(namespaceDO);
}
diff --git
a/shenyu-admin/src/main/resources/mappers/namespace-plugin-rel-sqlmap.xml
b/shenyu-admin/src/main/resources/mappers/namespace-plugin-rel-sqlmap.xml
index 2cad403728..1f6c742b25 100644
--- a/shenyu-admin/src/main/resources/mappers/namespace-plugin-rel-sqlmap.xml
+++ b/shenyu-admin/src/main/resources/mappers/namespace-plugin-rel-sqlmap.xml
@@ -129,8 +129,7 @@
FROM namespace_plugin_rel
WHERE plugin_id = #{pluginId, jdbcType=VARCHAR}
and namespace_id = #{namespaceId, jdbcType=VARCHAR}
- )
- npr
+ ) npr
LEFT JOIN plugin p ON npr.plugin_id = p.id
</select>