Skip to content

Commit

Permalink
[type:fix] publish event when enable selector and rule (apache#5762)
Browse files Browse the repository at this point in the history
Co-authored-by: aias00 <[email protected]>
  • Loading branch information
eye-gu and Aias00 authored Nov 12, 2024
1 parent b665ceb commit 31473eb
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,17 @@ public Boolean enabledByIdsAndNamespaceId(final List<String> ids, final Boolean
RuleDO before = JsonUtils.jsonToObject(JsonUtils.toJson(ruleDO), RuleDO.class);
ruleDO.setEnabled(enabled);
if (ruleMapper.updateEnable(id, enabled) > 0) {
ruleEventPublisher.onUpdated(ruleDO, before);
List<RuleConditionDO> conditionList = ruleConditionMapper.selectByQuery(new RuleConditionQuery(ruleDO.getId()));
List<RuleConditionDTO> conditions = conditionList.stream().map(item ->
RuleConditionDTO.builder()
.ruleId(item.getRuleId())
.id(item.getId())
.operator(item.getOperator())
.paramName(item.getParamName())
.paramValue(item.getParamValue())
.paramType(item.getParamType())
.build()).toList();
ruleEventPublisher.onUpdated(ruleDO, before, conditions, Collections.emptyList());
}
});
return Boolean.TRUE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,18 @@ public Boolean enabledByIdsAndNamespaceId(final List<String> ids, final Boolean
SelectorDO before = JsonUtils.jsonToObject(JsonUtils.toJson(selectorDO), SelectorDO.class);
selectorDO.setEnabled(enabled);
if (selectorMapper.updateEnable(id, enabled) > 0) {
List<SelectorConditionDO> conditionList = selectorConditionMapper.selectByQuery(new SelectorConditionQuery(selectorDO.getId()));
List<SelectorConditionDTO> selectorConditions = conditionList.stream().map(item -> {
SelectorConditionDTO selectorConditionDTO = new SelectorConditionDTO();
selectorConditionDTO.setId(item.getId());
selectorConditionDTO.setSelectorId(item.getSelectorId());
selectorConditionDTO.setParamType(item.getParamType());
selectorConditionDTO.setOperator(item.getOperator());
selectorConditionDTO.setParamName(item.getParamName());
selectorConditionDTO.setParamValue(item.getParamValue());
return selectorConditionDTO;
}).toList();
publishEvent(selectorDO, selectorConditions, Collections.emptyList());
selectorEventPublisher.onUpdated(selectorDO, before);
}
});
Expand Down

0 comments on commit 31473eb

Please sign in to comment.