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 552968d936 [type:fix] filter disable dict option (#5776)
552968d936 is described below
commit 552968d9363ee160bd512ed4297bc29acbcacfc9
Author: eye-gu <[email protected]>
AuthorDate: Tue Nov 12 18:00:22 2024 +0800
[type:fix] filter disable dict option (#5776)
---
.../shenyu/admin/service/impl/PluginHandleServiceImpl.java | 7 ++++++-
.../shenyu/admin/service/PluginHandleServiceTest.java | 13 ++++++++++++-
2 files changed, 18 insertions(+), 2 deletions(-)
diff --git
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/PluginHandleServiceImpl.java
b/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/PluginHandleServiceImpl.java
index 0022414e64..528c4a9fbd 100644
---
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/PluginHandleServiceImpl.java
+++
b/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/PluginHandleServiceImpl.java
@@ -187,7 +187,11 @@ public class PluginHandleServiceImpl implements
PluginHandleService {
private PluginHandleVO buildPluginHandleVO(final PluginHandleDO
pluginHandleDO) {
List<ShenyuDictVO> dictOptions = null;
if (pluginHandleDO.getDataType() == SELECT_BOX_DATA_TYPE) {
- dictOptions =
ListUtil.map(shenyuDictMapper.findByType(pluginHandleDO.getField()),
ShenyuDictVO::buildShenyuDictVO);
+ dictOptions =
shenyuDictMapper.findByType(pluginHandleDO.getField())
+ .stream()
+ .filter(item -> Objects.equals(item.getEnabled(),
Boolean.TRUE))
+ .map(ShenyuDictVO::buildShenyuDictVO)
+ .toList();
}
return PluginHandleVO.buildPluginHandleVO(pluginHandleDO, dictOptions);
}
@@ -204,6 +208,7 @@ public class PluginHandleServiceImpl implements
PluginHandleService {
?
Optional.ofNullable(shenyuDictMapper.findByTypeBatch(fieldList))
.orElseGet(ArrayList::new)
.stream()
+ .filter(item -> Objects.equals(item.getEnabled(),
Boolean.TRUE))
.map(ShenyuDictVO::buildShenyuDictVO)
.collect(Collectors.groupingBy(ShenyuDictVO::getType))
: new HashMap<>(0);
diff --git
a/shenyu-admin/src/test/java/org/apache/shenyu/admin/service/PluginHandleServiceTest.java
b/shenyu-admin/src/test/java/org/apache/shenyu/admin/service/PluginHandleServiceTest.java
index 785124cd48..53e861d600 100644
---
a/shenyu-admin/src/test/java/org/apache/shenyu/admin/service/PluginHandleServiceTest.java
+++
b/shenyu-admin/src/test/java/org/apache/shenyu/admin/service/PluginHandleServiceTest.java
@@ -187,7 +187,18 @@ public final class PluginHandleServiceTest {
.dateCreated(now)
.dateUpdated(now)
.build();
- return Collections.singletonList(result);
+ final ShenyuDictDO disableDict = ShenyuDictDO.builder()
+ .type("burstCapacity")
+ .dictCode("RATE_LIMITER_QPS")
+ .dictName("disable")
+ .dictValue("disable")
+ .desc("disable")
+ .enabled(false)
+ .sort(1)
+ .dateCreated(now)
+ .dateUpdated(now)
+ .build();
+ return List.of(result, disableDict);
}
@Test