This is an automated email from the ASF dual-hosted git repository.
xiaoyu 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 7e6e6da147 [type:fix]Fix the error of adding plugins of namespace
(#5701)
7e6e6da147 is described below
commit 7e6e6da14704346563fdf294d64245b7b646c100
Author: xcsnx <[email protected]>
AuthorDate: Thu Oct 17 16:08:30 2024 +0800
[type:fix]Fix the error of adding plugins of namespace (#5701)
* fix
* [type:fix] fix selectById sql problem
* fix
* fix
---------
Co-authored-by: ‘xcsnx’ <‘[email protected]’>
Co-authored-by: VampireAchao <[email protected]>
Co-authored-by: moremind <[email protected]>
Co-authored-by: aias00 <[email protected]>
---
.../shenyu/admin/model/entity/NamespacePluginRelDO.java | 4 ++--
.../apache/shenyu/admin/service/NamespacePluginService.java | 2 +-
.../shenyu/admin/service/impl/NamespacePluginServiceImpl.java | 11 ++++++-----
.../main/resources/mappers/namespace-plugin-rel-sqlmap.xml | 4 ++--
4 files changed, 11 insertions(+), 10 deletions(-)
diff --git
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/entity/NamespacePluginRelDO.java
b/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/entity/NamespacePluginRelDO.java
index 08d2700d68..96b94f739a 100644
---
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/entity/NamespacePluginRelDO.java
+++
b/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/entity/NamespacePluginRelDO.java
@@ -18,7 +18,7 @@
package org.apache.shenyu.admin.model.entity;
import org.apache.shenyu.admin.model.dto.NamespacePluginDTO;
-
+import org.apache.shenyu.common.utils.UUIDUtils;
import java.sql.Timestamp;
import java.util.Objects;
import java.util.Optional;
@@ -195,7 +195,7 @@ public final class NamespacePluginRelDO extends BaseDO {
return Optional.ofNullable(pluginDO).map(item -> {
Timestamp currentTime = new Timestamp(System.currentTimeMillis());
return NamespacePluginRelDO.builder()
- .id(item.getId())
+ .id(UUIDUtils.getInstance().generateShortUuid())
.config(item.getConfig())
.enabled(item.getEnabled())
.sort(item.getSort())
diff --git
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/NamespacePluginService.java
b/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/NamespacePluginService.java
index e1916ff323..6c68d60f8e 100644
---
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/NamespacePluginService.java
+++
b/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/NamespacePluginService.java
@@ -50,7 +50,7 @@ public interface NamespacePluginService extends
PageService<NamespacePluginQuery
* @param pluginId pluginId.
* @return the string
*/
- String create(String namespaceId, String pluginId);
+ NamespacePluginVO create(String namespaceId, String pluginId);
/**
* Create string.
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 3ac7db7b17..fcedd9e09b 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
@@ -20,6 +20,7 @@ package org.apache.shenyu.admin.service.impl;
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.NamespacePluginRelMapper;
import org.apache.shenyu.admin.mapper.PluginMapper;
import org.apache.shenyu.admin.model.dto.PluginDTO;
@@ -77,15 +78,15 @@ public class NamespacePluginServiceImpl implements
NamespacePluginService {
}
@Override
- public String create(final String namespaceId, final String pluginId) {
- NamespacePluginVO namespacePluginVO =
namespacePluginRelMapper.selectByPluginIdAndNamespaceId(pluginId, namespaceId);
- if (!Objects.isNull(namespacePluginVO)) {
- return AdminConstants.NAMESPACE_PLUGIN_EXIST;
+ public NamespacePluginVO create(final String namespaceId, final String
pluginId) {
+ NamespacePluginVO existNamespacePluginVO =
namespacePluginRelMapper.selectByPluginIdAndNamespaceId(pluginId, namespaceId);
+ if (!Objects.isNull(existNamespacePluginVO)) {
+ throw new
ShenyuAdminException(AdminConstants.NAMESPACE_PLUGIN_EXIST);
}
PluginDO pluginDO = pluginMapper.selectById(pluginId);
NamespacePluginRelDO namespacePluginRelDO =
NamespacePluginRelDO.buildNamespacePluginRelDO(pluginDO, namespaceId);
namespacePluginRelMapper.insertSelective(namespacePluginRelDO);
- return ShenyuResultMessage.CREATE_SUCCESS;
+ return
namespacePluginRelMapper.selectByPluginIdAndNamespaceId(pluginId, namespaceId);
}
@Override
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 1e3256213e..6ca0eb4d8a 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
@@ -333,10 +333,10 @@
#{config, jdbcType=VARCHAR},
</if>
<if test="sort != null">
- #{sort, jdbcType=VARCHAR},
+ #{sort, jdbcType=INTEGER},
</if>
<if test="enabled != null">
- #{enabled, jdbcType=BOOLEAN},
+ #{enabled, jdbcType=INTEGER},
</if>
<if test="dateCreated != null">
#{dateCreated, jdbcType=TIMESTAMP},