@Override
    public int update(final RuleDTO ruleDTO) {
        final RuleDO before = ruleMapper.selectById(ruleDTO.getId());
        Assert.notNull(before, "the updated rule is not found");
        RuleDO ruleDO = RuleDO.buildRuleDO(ruleDTO);
        final int ruleCount = ruleMapper.updateSelective(ruleDO);

        // need old data for cleaning
        List<RuleConditionDO> beforeRuleCondition = ruleConditionMapper.selectByQuery(new RuleConditionQuery(ruleDO.getId()));
        List<RuleConditionDTO> beforeCondition = beforeRuleCondition.stream().map(ruleConditionDO ->
                RuleConditionDTO.builder()
                        .ruleId(ruleConditionDO.getRuleId())
                        .operator(ruleConditionDO.getOperator())
                        .paramName(ruleConditionDO.getParamName())
                        .paramType(ruleConditionDO.getParamType())
                        .paramValue(ruleConditionDO.getParamValue())
                        .build()).collect(Collectors.toList());
        List<RuleConditionDTO> currentCondition = ruleDTO.getRuleConditions().stream().map(ruleConditionDTO ->
                RuleConditionDTO.builder()
                        .ruleId(ruleConditionDTO.getRuleId())
                        .operator(ruleConditionDTO.getOperator())
                        .paramName(ruleConditionDTO.getParamName())
                        .paramType(ruleConditionDTO.getParamType())
                        .paramValue(ruleConditionDTO.getParamValue())
                        .build()).collect(Collectors.toList());
        if (CollectionUtils.isEqualCollection(beforeCondition, currentCondition)) {
            beforeRuleCondition = Collections.emptyList();
        }
        //delete rule condition then add
        ruleConditionMapper.deleteByQuery(new RuleConditionQuery(ruleDO.getId()));

        // insert new condition
        addCondition(ruleDO, ruleDTO.getRuleConditions());
        if (ruleCount > 0) {
            ruleEventPublisher.onUpdated(ruleDO, before, ruleDTO.getRuleConditions(), beforeRuleCondition);
        }
        return ruleCount;
    }
create or update rule.

@param ruleDTO {@linkplain RuleDTO}
@return rows
shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/RuleServiceImpl.java