diff --git a/pigx-common/pigx-common-data/src/main/java/com/pig4cloud/pigx/common/data/datascope/DataScopeInnerInterceptor.java b/pigx-common/pigx-common-data/src/main/java/com/pig4cloud/pigx/common/data/datascope/DataScopeInnerInterceptor.java index 0e889b87e..c355d20d0 100644 --- a/pigx-common/pigx-common-data/src/main/java/com/pig4cloud/pigx/common/data/datascope/DataScopeInnerInterceptor.java +++ b/pigx-common/pigx-common-data/src/main/java/com/pig4cloud/pigx/common/data/datascope/DataScopeInnerInterceptor.java @@ -37,8 +37,15 @@ public class DataScopeInnerInterceptor implements DataScopeInterceptor { return; } - // 返回true 不拦截直接返回原始 SQL - if (dataScopeHandle.calcScope(dataScope)) { + // 返回true 不拦截直接返回原始 SQL (只针对 * 查询) + if (dataScopeHandle.calcScope(dataScope) && DataScopeFuncEnum.ALL.equals(dataScope.getFunc())) { + return; + } + + // 返回true 不拦截直接返回原始 SQL (只针对 COUNT 查询) + if (dataScopeHandle.calcScope(dataScope) && DataScopeFuncEnum.COUNT.equals(dataScope.getFunc())) { + mpBs.sql(String.format("SELECT %s FROM (%s) temp_data_scope", + dataScope.getFunc().getType(), originalSql)); return; }