Skip to content

Commit

Permalink
[type:fix] filter disable dict option (apache#5776)
Browse files Browse the repository at this point in the history
  • Loading branch information
eye-gu authored Nov 12, 2024
1 parent 31473eb commit 552968d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,11 @@ public void onPluginDeleted(final BatchPluginDeletedEvent event) {
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);
}
Expand All @@ -204,6 +208,7 @@ private List<PluginHandleVO> buildPluginHandleVO(final List<PluginHandleDO> 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,18 @@ private List<ShenyuDictDO> 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
Expand Down

0 comments on commit 552968d

Please sign in to comment.