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) {} + } } // 只要有任一配置(脚本/页面/规则)即视为有效快照