From 552968d9363ee160bd512ed4297bc29acbcacfc9 Mon Sep 17 00:00:00 2001 From: eye-gu <734164350@qq.com> Date: Tue, 12 Nov 2024 18:00:22 +0800 Subject: [PATCH] [type:fix] filter disable dict option (#5776) --- .../admin/service/impl/PluginHandleServiceImpl.java | 7 ++++++- .../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 0022414e64f3..528c4a9fbddf 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 void onPluginDeleted(final BatchPluginDeletedEvent event) { private PluginHandleVO buildPluginHandleVO(final PluginHandleDO pluginHandleDO) { List 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 @@ private List buildPluginHandleVO(final List plug ? 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 785124cd4877..53e861d600de 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 @@ private List buildShenyuDictDOs() { .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