This is an automated email from the ASF dual-hosted git repository.

liuhongyu 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 31473ebacb [type:fix] publish event when enable selector and rule 
(#5762)
31473ebacb is described below

commit 31473ebacb28850a3907d9167a541582c401fd91
Author: eye-gu <734164...@qq.com>
AuthorDate: Tue Nov 12 15:36:37 2024 +0800

    [type:fix] publish event when enable selector and rule (#5762)
    
    Co-authored-by: aias00 <liuhon...@apache.org>
---
 .../apache/shenyu/admin/service/impl/RuleServiceImpl.java    | 12 +++++++++++-
 .../shenyu/admin/service/impl/SelectorServiceImpl.java       | 12 ++++++++++++
 2 files changed, 23 insertions(+), 1 deletion(-)

diff --git 
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/RuleServiceImpl.java
 
b/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/RuleServiceImpl.java
index 3618e14431..d170e76e04 100644
--- 
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/RuleServiceImpl.java
+++ 
b/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/RuleServiceImpl.java
@@ -302,7 +302,17 @@ public class RuleServiceImpl implements RuleService {
             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;
diff --git 
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/SelectorServiceImpl.java
 
b/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/SelectorServiceImpl.java
index ca148aaec1..04b315acbf 100644
--- 
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/SelectorServiceImpl.java
+++ 
b/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/SelectorServiceImpl.java
@@ -496,6 +496,18 @@ public class SelectorServiceImpl implements 
SelectorService {
             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);
             }
         });

Reply via email to