@Override
    @Transactional(rollbackFor = Exception.class)
    public ConfigImportResult importData(final String namespace, final List<RuleDTO> ruleList, final ConfigsImportContext context) {
        if (CollectionUtils.isEmpty(ruleList)) {
            return ConfigImportResult.success();
        }
        Map<String, String> selectorIdMapping = context.getSelectorIdMapping();
        Map<String, List<RuleDO>> selectorRuleMap = ruleMapper
                .selectAllByNamespaceId(namespace)
                .stream()
                .collect(Collectors.groupingBy(RuleDO::getSelectorId));
        
        int successCount = 0;
        StringBuilder errorMsgBuilder = new StringBuilder();
        for (RuleDTO ruleDTO : ruleList) {
            String selectorId = ruleDTO.getSelectorId();
            String ruleName = ruleDTO.getName();

            String newSelectorId = selectorIdMapping.get(selectorId);
            if (Objects.isNull(newSelectorId)) {
                errorMsgBuilder
                        .append(ruleName)
                        .append(",");
                continue;
            }
            Set<String> existRuleNameSet = selectorRuleMap
                    .getOrDefault(newSelectorId, Lists.newArrayList())
                    .stream()
                    .map(RuleDO::getName)
                    .collect(Collectors.toSet());
            
            if (existRuleNameSet.contains(ruleName)) {
                errorMsgBuilder
                        .append(ruleName)
                        .append(",");
                continue;
            }
            ruleDTO.setNamespaceId(namespace);
            ruleDTO.setSelectorId(newSelectorId);
            String ruleId = UUIDUtils.getInstance().generateShortUuid();
            ruleDTO.setId(ruleId);
            RuleDO ruleDO = RuleDO.buildRuleDO(ruleDTO);
            final int ruleCount = ruleMapper.insertSelective(ruleDO);
            Optional.ofNullable(ruleDTO.getRuleConditions())
                            .orElse(Collections.emptyList()).forEach(c -> {
                                c.setRuleId(ruleId);
                                c.setId(null);
                            });
            addCondition(ruleDO, ruleDTO.getRuleConditions());
            if (ruleCount > 0) {
                successCount++;
            }
        }
        if (StringUtils.isNotEmpty(errorMsgBuilder)) {
            errorMsgBuilder.setLength(errorMsgBuilder.length() - 1);
            return ConfigImportResult
                    .fail(successCount, "import fail rule: " + errorMsgBuilder);
        }
        return ConfigImportResult.success(successCount);
    }
find page of rule by query.

@param ruleQuery {@linkplain RuleQuery}
@return {@linkplain CommonPager}
shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/RuleServiceImpl.java