From af4b2bde7501fc16c5228f49faa48ade2a72bdc4 Mon Sep 17 00:00:00 2001 From: mediabot-pt <295750538+mediabot-pt@users.noreply.github.com> Date: Sun, 12 Jul 2026 23:21:14 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E7=A7=BB=E9=99=A4=E9=A3=8E?= =?UTF-8?q?=E9=99=A9=E8=A7=84=E5=88=99=20siteType=20fallback=20=E9=80=BB?= =?UTF-8?q?=E8=BE=91=EF=BC=8C=E4=BB=85=E6=8C=89=E7=AB=99=E7=82=B9=20ID=20?= =?UTF-8?q?=E6=9F=A5=E6=89=BE=E4=B8=93=E5=B1=9E=E8=A7=84=E5=88=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/SiteSnapshotServiceImpl.java | 35 ++++++------------- 1 file changed, 11 insertions(+), 24 deletions(-) diff --git a/par-core/src/main/java/com/par/core/service/impl/SiteSnapshotServiceImpl.java b/par-core/src/main/java/com/par/core/service/impl/SiteSnapshotServiceImpl.java index 0d9a3f4..845d28c 100644 --- a/par-core/src/main/java/com/par/core/service/impl/SiteSnapshotServiceImpl.java +++ b/par-core/src/main/java/com/par/core/service/impl/SiteSnapshotServiceImpl.java @@ -100,36 +100,23 @@ public class SiteSnapshotServiceImpl implements SiteSnapshotService { snapshot.put("pagesSource", pages.containsKey("source") ? pages.get("source") : "custom"); } - // 3. 风险规则(优先按站点专属规则查找,无则 fallback 到站点类型规则) - RiskRule matchedRule = null; - // 3a. 按站点 ID 查找专属规则 + // 3. 风险规则(按站点 ID 查找专属规则) if (siteId != null) { - matchedRule = riskRuleMapper.selectOne( + var matchedRule = riskRuleMapper.selectOne( new com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper() .eq(RiskRule::getSiteId, siteId) .eq(RiskRule::getDeleted, 0) .orderByDesc(RiskRule::getId) .last("limit 1")); - } - // 3b. 无专属规则时 fallback 到站点类型规则 - if (matchedRule == null && siteType != null) { - matchedRule = riskRuleMapper.selectOne( - new com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper() - .eq(RiskRule::getSiteType, siteType) - .eq(RiskRule::getDeleted, 0) - .orderByDesc(RiskRule::getId) - .last("limit 1")); - } - if (matchedRule != null) { - try { - List> rulesList = om.readValue(matchedRule.getRulesJson(), - new TypeReference>>() {}); - snapshot.put("riskRules", rulesList); - snapshot.put("riskRulesVersion", matchedRule.getVersion()); - log.debug("快照风险规则: siteId={} ruleSource={} ruleVersion={}", siteId, - matchedRule.getSiteId() != null && matchedRule.getSiteId().equals(siteId) ? "site" : "siteType", - matchedRule.getVersion()); - } catch (Exception ignored) {} + if (matchedRule != null) { + try { + List> rulesList = om.readValue(matchedRule.getRulesJson(), + new TypeReference>>() {}); + snapshot.put("riskRules", rulesList); + snapshot.put("riskRulesVersion", matchedRule.getVersion()); + log.debug("快照风险规则: siteId={} ruleVersion={}", siteId, matchedRule.getVersion()); + } catch (Exception ignored) {} + } } // 只要有任一配置(脚本/页面/规则)即视为有效快照