diff --git a/example/example-app/example-app-cmd-domain/pom.xml b/example/example-app/example-app-cmd-domain/pom.xml
index 4020f607d..caa94bd25 100644
--- a/example/example-app/example-app-cmd-domain/pom.xml
+++ b/example/example-app/example-app-cmd-domain/pom.xml
@@ -6,7 +6,7 @@
com.codingapi.springboot
example-app
- 3.4.35
+ 3.4.36
../pom.xml
diff --git a/example/example-app/example-app-cmd-meta/pom.xml b/example/example-app/example-app-cmd-meta/pom.xml
index b8a7e3d6a..1f99e3d75 100644
--- a/example/example-app/example-app-cmd-meta/pom.xml
+++ b/example/example-app/example-app-cmd-meta/pom.xml
@@ -6,7 +6,7 @@
com.codingapi.springboot
example-app
- 3.4.35
+ 3.4.36
../pom.xml
diff --git a/example/example-app/example-app-query/pom.xml b/example/example-app/example-app-query/pom.xml
index e8fbfbc46..d596ef7a6 100644
--- a/example/example-app/example-app-query/pom.xml
+++ b/example/example-app/example-app-query/pom.xml
@@ -6,7 +6,7 @@
com.codingapi.springboot
example-app
- 3.4.35
+ 3.4.36
../pom.xml
diff --git a/example/example-app/pom.xml b/example/example-app/pom.xml
index 3049a6a28..bed9922e3 100644
--- a/example/example-app/pom.xml
+++ b/example/example-app/pom.xml
@@ -6,7 +6,7 @@
com.codingapi.springboot
springboot-example
- 3.4.35
+ 3.4.36
../pom.xml
pom
diff --git a/example/example-domain/example-domain-leave/pom.xml b/example/example-domain/example-domain-leave/pom.xml
index bc44444ac..d3ccf773f 100644
--- a/example/example-domain/example-domain-leave/pom.xml
+++ b/example/example-domain/example-domain-leave/pom.xml
@@ -6,7 +6,7 @@
com.codingapi.springboot
example-domain
- 3.4.35
+ 3.4.36
../pom.xml
diff --git a/example/example-domain/example-domain-user/pom.xml b/example/example-domain/example-domain-user/pom.xml
index a037bb495..4b3414de8 100644
--- a/example/example-domain/example-domain-user/pom.xml
+++ b/example/example-domain/example-domain-user/pom.xml
@@ -6,7 +6,7 @@
com.codingapi.springboot
example-domain
- 3.4.35
+ 3.4.36
../pom.xml
diff --git a/example/example-domain/pom.xml b/example/example-domain/pom.xml
index 5501e25f1..fb1b38e03 100644
--- a/example/example-domain/pom.xml
+++ b/example/example-domain/pom.xml
@@ -5,7 +5,7 @@
com.codingapi.springboot
springboot-example
- 3.4.35
+ 3.4.36
../pom.xml
4.0.0
diff --git a/example/example-infra/example-infra-flow/pom.xml b/example/example-infra/example-infra-flow/pom.xml
index 21aec6360..b386702a1 100644
--- a/example/example-infra/example-infra-flow/pom.xml
+++ b/example/example-infra/example-infra-flow/pom.xml
@@ -5,7 +5,7 @@
com.codingapi.springboot
example-infra
- 3.4.35
+ 3.4.36
../pom.xml
diff --git a/example/example-infra/example-infra-jpa/pom.xml b/example/example-infra/example-infra-jpa/pom.xml
index 7806b63f0..8767d8ec5 100644
--- a/example/example-infra/example-infra-jpa/pom.xml
+++ b/example/example-infra/example-infra-jpa/pom.xml
@@ -5,7 +5,7 @@
com.codingapi.springboot
example-infra
- 3.4.35
+ 3.4.36
../pom.xml
diff --git a/example/example-infra/example-infra-security/pom.xml b/example/example-infra/example-infra-security/pom.xml
index ad5a7a461..9acc8a4d1 100644
--- a/example/example-infra/example-infra-security/pom.xml
+++ b/example/example-infra/example-infra-security/pom.xml
@@ -6,7 +6,7 @@
com.codingapi.springboot
example-infra
- 3.4.35
+ 3.4.36
../pom.xml
diff --git a/example/example-infra/pom.xml b/example/example-infra/pom.xml
index af47ca62f..0d5d9336f 100644
--- a/example/example-infra/pom.xml
+++ b/example/example-infra/pom.xml
@@ -6,7 +6,7 @@
com.codingapi.springboot
springboot-example
- 3.4.35
+ 3.4.36
../pom.xml
pom
diff --git a/example/example-interface/pom.xml b/example/example-interface/pom.xml
index 848df9f5d..b642c6439 100644
--- a/example/example-interface/pom.xml
+++ b/example/example-interface/pom.xml
@@ -6,7 +6,7 @@
com.codingapi.springboot
springboot-example
- 3.4.35
+ 3.4.36
example-interface
diff --git a/example/example-server/pom.xml b/example/example-server/pom.xml
index 3ce4888c3..1951ce377 100644
--- a/example/example-server/pom.xml
+++ b/example/example-server/pom.xml
@@ -5,7 +5,7 @@
springboot-example
com.codingapi.springboot
- 3.4.35
+ 3.4.36
4.0.0
diff --git a/example/pom.xml b/example/pom.xml
index 2add9d2ed..41268df03 100644
--- a/example/pom.xml
+++ b/example/pom.xml
@@ -19,7 +19,7 @@
springboot-example
- 3.4.35
+ 3.4.36
springboot-example
springboot-example project for Spring Boot
diff --git a/pom.xml b/pom.xml
index 789088e92..e964864cc 100644
--- a/pom.xml
+++ b/pom.xml
@@ -12,7 +12,7 @@
com.codingapi.springboot
springboot-parent
- 3.4.35
+ 3.4.36
https://github.com/codingapi/springboot-framewrok
springboot-parent
diff --git a/springboot-starter-data-authorization/pom.xml b/springboot-starter-data-authorization/pom.xml
index 0830a3e95..a4f9fc2d0 100644
--- a/springboot-starter-data-authorization/pom.xml
+++ b/springboot-starter-data-authorization/pom.xml
@@ -6,7 +6,7 @@
com.codingapi.springboot
springboot-parent
- 3.4.35
+ 3.4.36
springboot-starter-data-authorization
diff --git a/springboot-starter-data-authorization/src/main/java/com/codingapi/springboot/authorization/DataAuthorizationContext.java b/springboot-starter-data-authorization/src/main/java/com/codingapi/springboot/authorization/DataAuthorizationContext.java
index 9af58d8ad..1e50aee7d 100644
--- a/springboot-starter-data-authorization/src/main/java/com/codingapi/springboot/authorization/DataAuthorizationContext.java
+++ b/springboot-starter-data-authorization/src/main/java/com/codingapi/springboot/authorization/DataAuthorizationContext.java
@@ -1,9 +1,12 @@
package com.codingapi.springboot.authorization;
import com.codingapi.springboot.authorization.filter.DataAuthorizationFilter;
+import com.codingapi.springboot.authorization.filter.DefaultSkipAuthorizationFilter;
import com.codingapi.springboot.authorization.handler.Condition;
-import com.codingapi.springboot.authorization.interceptor.SQLInterceptState;
+import com.codingapi.springboot.authorization.filter.SkipAuthorizationFilter;
+import com.codingapi.springboot.authorization.interceptor.SQLExecuteState;
import lombok.Getter;
+import lombok.Setter;
import org.springframework.util.StringUtils;
import java.util.ArrayList;
@@ -19,8 +22,19 @@ public class DataAuthorizationContext {
private final List filters;
+ @Setter
+ private SkipAuthorizationFilter skipAuthorizationFilter;
+
private DataAuthorizationContext() {
this.filters = new ArrayList<>();
+ this.skipAuthorizationFilter = new DefaultSkipAuthorizationFilter();
+ }
+
+ /**
+ * 跳过拦截的处理机制
+ */
+ public String skipSQLFilter(String sql){
+ return this.skipAuthorizationFilter.filter(sql);
}
/**
@@ -47,7 +61,7 @@ public void clearDataAuthorizationFilters() {
* @return T
* @param 泛型
*/
- public T columnAuthorization(SQLInterceptState interceptState, String tableName, String columnName, T value) {
+ public T columnAuthorization(SQLExecuteState interceptState, String tableName, String columnName, T value) {
if (interceptState != null && interceptState.hasIntercept()) {
String realTableName = interceptState.getTableName(tableName);
String realColumnName = interceptState.getColumnName(tableName,columnName);
diff --git a/springboot-starter-data-authorization/src/main/java/com/codingapi/springboot/authorization/filter/DefaultSkipAuthorizationFilter.java b/springboot-starter-data-authorization/src/main/java/com/codingapi/springboot/authorization/filter/DefaultSkipAuthorizationFilter.java
new file mode 100644
index 000000000..253dc0c17
--- /dev/null
+++ b/springboot-starter-data-authorization/src/main/java/com/codingapi/springboot/authorization/filter/DefaultSkipAuthorizationFilter.java
@@ -0,0 +1,9 @@
+package com.codingapi.springboot.authorization.filter;
+
+public class DefaultSkipAuthorizationFilter implements SkipAuthorizationFilter{
+
+ @Override
+ public String filter(String sql) {
+ return sql;
+ }
+}
diff --git a/springboot-starter-data-authorization/src/main/java/com/codingapi/springboot/authorization/filter/SkipAuthorizationFilter.java b/springboot-starter-data-authorization/src/main/java/com/codingapi/springboot/authorization/filter/SkipAuthorizationFilter.java
new file mode 100644
index 000000000..df2fb0828
--- /dev/null
+++ b/springboot-starter-data-authorization/src/main/java/com/codingapi/springboot/authorization/filter/SkipAuthorizationFilter.java
@@ -0,0 +1,10 @@
+package com.codingapi.springboot.authorization.filter;
+
+/**
+ * 跳过数据权限拦截处理机制
+ */
+public interface SkipAuthorizationFilter {
+
+ String filter(String sql);
+
+}
diff --git a/springboot-starter-data-authorization/src/main/java/com/codingapi/springboot/authorization/handler/ColumnHandler.java b/springboot-starter-data-authorization/src/main/java/com/codingapi/springboot/authorization/handler/ColumnHandler.java
index 0f1da82ad..2867f1b25 100644
--- a/springboot-starter-data-authorization/src/main/java/com/codingapi/springboot/authorization/handler/ColumnHandler.java
+++ b/springboot-starter-data-authorization/src/main/java/com/codingapi/springboot/authorization/handler/ColumnHandler.java
@@ -1,6 +1,6 @@
package com.codingapi.springboot.authorization.handler;
-import com.codingapi.springboot.authorization.interceptor.SQLInterceptState;
+import com.codingapi.springboot.authorization.interceptor.SQLExecuteState;
import java.io.InputStream;
import java.io.Reader;
@@ -13,62 +13,62 @@
*/
public interface ColumnHandler {
- String getString(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, String value);
+ String getString(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, String value);
- boolean getBoolean(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, boolean value);
+ boolean getBoolean(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, boolean value);
- byte getByte(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, byte value);
+ byte getByte(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, byte value);
- short getShort(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, short value);
+ short getShort(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, short value);
- int getInt(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, int value);
+ int getInt(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, int value);
- long getLong(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, long value);
+ long getLong(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, long value);
- float getFloat(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, float value);
+ float getFloat(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, float value);
- double getDouble(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, double value);
+ double getDouble(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, double value);
- BigDecimal getBigDecimal(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, BigDecimal value);
+ BigDecimal getBigDecimal(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, BigDecimal value);
- byte[] getBytes(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, byte[] value);
+ byte[] getBytes(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, byte[] value);
- Date getDate(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, Date value);
+ Date getDate(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, Date value);
- Time getTime(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, Time value);
+ Time getTime(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, Time value);
- Timestamp getTimestamp(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, Timestamp value);
+ Timestamp getTimestamp(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, Timestamp value);
- InputStream getAsciiStream(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, InputStream value);
+ InputStream getAsciiStream(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, InputStream value);
- InputStream getUnicodeStream(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, InputStream value);
+ InputStream getUnicodeStream(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, InputStream value);
- InputStream getBinaryStream(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, InputStream value);
+ InputStream getBinaryStream(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, InputStream value);
- Object getObject(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, Object value);
+ Object getObject(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, Object value);
- Reader getCharacterStream(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, Reader value);
+ Reader getCharacterStream(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, Reader value);
- Ref getRef(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, Ref value);
+ Ref getRef(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, Ref value);
- Blob getBlob(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, Blob value);
+ Blob getBlob(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, Blob value);
- Clob getClob(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, Clob value);
+ Clob getClob(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, Clob value);
- Array getArray(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, Array value);
+ Array getArray(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, Array value);
- URL getURL(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, URL value);
+ URL getURL(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, URL value);
- NClob getNClob(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, NClob value);
+ NClob getNClob(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, NClob value);
- SQLXML getSQLXML(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, SQLXML value);
+ SQLXML getSQLXML(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, SQLXML value);
- String getNString(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, String value);
+ String getNString(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, String value);
- Reader getNCharacterStream(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, Reader value);
+ Reader getNCharacterStream(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, Reader value);
- RowId getRowId(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, RowId value);
+ RowId getRowId(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, RowId value);
- T getObject(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, T value, Class type);
+ T getObject(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, T value, Class type);
}
diff --git a/springboot-starter-data-authorization/src/main/java/com/codingapi/springboot/authorization/handler/ColumnHandlerContext.java b/springboot-starter-data-authorization/src/main/java/com/codingapi/springboot/authorization/handler/ColumnHandlerContext.java
index fc0ef6d3f..f591eaf1b 100644
--- a/springboot-starter-data-authorization/src/main/java/com/codingapi/springboot/authorization/handler/ColumnHandlerContext.java
+++ b/springboot-starter-data-authorization/src/main/java/com/codingapi/springboot/authorization/handler/ColumnHandlerContext.java
@@ -1,6 +1,6 @@
package com.codingapi.springboot.authorization.handler;
-import com.codingapi.springboot.authorization.interceptor.SQLInterceptState;
+import com.codingapi.springboot.authorization.interceptor.SQLExecuteState;
import lombok.Getter;
import lombok.Setter;
@@ -26,119 +26,119 @@ private ColumnHandlerContext() {
private ColumnHandler columnHandler;
- public String getString(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, String value) {
+ public String getString(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, String value) {
return columnHandler.getString(interceptState, columnIndex, tableName, columnName, value);
}
- public short getShort(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, short value) {
+ public short getShort(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, short value) {
return columnHandler.getShort(interceptState, columnIndex, tableName, columnName, value);
}
- public boolean getBoolean(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, boolean value) {
+ public boolean getBoolean(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, boolean value) {
return columnHandler.getBoolean(interceptState, columnIndex, tableName, columnName, value);
}
- public byte getByte(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, byte value) {
+ public byte getByte(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, byte value) {
return columnHandler.getByte(interceptState, columnIndex, tableName, columnName, value);
}
- public int getInt(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, int value) {
+ public int getInt(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, int value) {
return columnHandler.getInt(interceptState, columnIndex, tableName, columnName, value);
}
- public long getLong(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, long value) {
+ public long getLong(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, long value) {
return columnHandler.getLong(interceptState, columnIndex, tableName, columnName, value);
}
- public float getFloat(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, float value) {
+ public float getFloat(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, float value) {
return columnHandler.getFloat(interceptState, columnIndex, tableName, columnName, value);
}
- public double getDouble(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, double value) {
+ public double getDouble(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, double value) {
return columnHandler.getDouble(interceptState, columnIndex, tableName, columnName, value);
}
- public BigDecimal getBigDecimal(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, BigDecimal value) {
+ public BigDecimal getBigDecimal(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, BigDecimal value) {
return columnHandler.getBigDecimal(interceptState, columnIndex, tableName, columnName, value);
}
- public byte[] getBytes(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, byte[] value) {
+ public byte[] getBytes(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, byte[] value) {
return columnHandler.getBytes(interceptState, columnIndex, tableName, columnName, value);
}
- public Timestamp getTimestamp(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, Timestamp value) {
+ public Timestamp getTimestamp(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, Timestamp value) {
return columnHandler.getTimestamp(interceptState, columnIndex, tableName, columnName, value);
}
- public Time getTime(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, Time value) {
+ public Time getTime(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, Time value) {
return columnHandler.getTime(interceptState, columnIndex, tableName, columnName, value);
}
- public Date getDate(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, Date value) {
+ public Date getDate(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, Date value) {
return columnHandler.getDate(interceptState, columnIndex, tableName, columnName, value);
}
- public InputStream getAsciiStream(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, InputStream value) {
+ public InputStream getAsciiStream(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, InputStream value) {
return columnHandler.getAsciiStream(interceptState, columnIndex, tableName, columnName, value);
}
- public InputStream getUnicodeStream(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, InputStream value) {
+ public InputStream getUnicodeStream(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, InputStream value) {
return columnHandler.getUnicodeStream(interceptState, columnIndex, tableName, columnName, value);
}
- public InputStream getBinaryStream(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, InputStream value) {
+ public InputStream getBinaryStream(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, InputStream value) {
return columnHandler.getBinaryStream(interceptState, columnIndex, tableName, columnName, value);
}
- public Object getObject(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, Object value) {
+ public Object getObject(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, Object value) {
return columnHandler.getObject(interceptState, columnIndex, tableName, columnName, value);
}
- public Reader getCharacterStream(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, Reader value) {
+ public Reader getCharacterStream(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, Reader value) {
return columnHandler.getCharacterStream(interceptState, columnIndex, tableName, columnName, value);
}
- public Ref getRef(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, Ref value) {
+ public Ref getRef(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, Ref value) {
return columnHandler.getRef(interceptState, columnIndex, tableName, columnName, value);
}
- public Blob getBlob(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, Blob value) {
+ public Blob getBlob(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, Blob value) {
return columnHandler.getBlob(interceptState, columnIndex, tableName, columnName, value);
}
- public Clob getClob(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, Clob value) {
+ public Clob getClob(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, Clob value) {
return columnHandler.getClob(interceptState, columnIndex, tableName, columnName, value);
}
- public Array getArray(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, Array value) {
+ public Array getArray(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, Array value) {
return columnHandler.getArray(interceptState, columnIndex, tableName, columnName, value);
}
- public URL getURL(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, URL value) {
+ public URL getURL(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, URL value) {
return columnHandler.getURL(interceptState, columnIndex, tableName, columnName, value);
}
- public NClob getNClob(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, NClob value) {
+ public NClob getNClob(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, NClob value) {
return columnHandler.getNClob(interceptState, columnIndex, tableName, columnName, value);
}
- public SQLXML getSQLXML(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, SQLXML value) {
+ public SQLXML getSQLXML(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, SQLXML value) {
return columnHandler.getSQLXML(interceptState, columnIndex, tableName, columnName, value);
}
- public String getNString(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, String value) {
+ public String getNString(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, String value) {
return columnHandler.getNString(interceptState, columnIndex, tableName, columnName, value);
}
- public Reader getNCharacterStream(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, Reader value) {
+ public Reader getNCharacterStream(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, Reader value) {
return columnHandler.getNCharacterStream(interceptState, columnIndex, tableName, columnName, value);
}
- public RowId getRowId(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, RowId value) {
+ public RowId getRowId(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, RowId value) {
return columnHandler.getRowId(interceptState, columnIndex, tableName, columnName, value);
}
- public T getObject(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, T value, Class type) {
+ public T getObject(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, T value, Class type) {
return columnHandler.getObject(interceptState, columnIndex, tableName, columnName, value, type);
}
}
diff --git a/springboot-starter-data-authorization/src/main/java/com/codingapi/springboot/authorization/handler/DefaultColumnHandler.java b/springboot-starter-data-authorization/src/main/java/com/codingapi/springboot/authorization/handler/DefaultColumnHandler.java
index ff60b751e..ea6282abb 100644
--- a/springboot-starter-data-authorization/src/main/java/com/codingapi/springboot/authorization/handler/DefaultColumnHandler.java
+++ b/springboot-starter-data-authorization/src/main/java/com/codingapi/springboot/authorization/handler/DefaultColumnHandler.java
@@ -1,7 +1,7 @@
package com.codingapi.springboot.authorization.handler;
import com.codingapi.springboot.authorization.DataAuthorizationContext;
-import com.codingapi.springboot.authorization.interceptor.SQLInterceptState;
+import com.codingapi.springboot.authorization.interceptor.SQLExecuteState;
import java.io.InputStream;
import java.io.Reader;
@@ -15,147 +15,147 @@
public class DefaultColumnHandler implements ColumnHandler {
@Override
- public String getString(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, String value) {
+ public String getString(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, String value) {
return DataAuthorizationContext.getInstance().columnAuthorization(interceptState,tableName, columnName, value);
}
@Override
- public boolean getBoolean(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, boolean value) {
+ public boolean getBoolean(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, boolean value) {
return DataAuthorizationContext.getInstance().columnAuthorization(interceptState,tableName, columnName, value);
}
@Override
- public byte getByte(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, byte value) {
+ public byte getByte(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, byte value) {
return DataAuthorizationContext.getInstance().columnAuthorization(interceptState,tableName, columnName, value);
}
@Override
- public short getShort(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, short value) {
+ public short getShort(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, short value) {
return DataAuthorizationContext.getInstance().columnAuthorization(interceptState,tableName, columnName, value);
}
@Override
- public int getInt(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, int value) {
+ public int getInt(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, int value) {
return DataAuthorizationContext.getInstance().columnAuthorization(interceptState,tableName, columnName, value);
}
@Override
- public long getLong(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, long value) {
+ public long getLong(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, long value) {
return DataAuthorizationContext.getInstance().columnAuthorization(interceptState,tableName, columnName, value);
}
@Override
- public float getFloat(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, float value) {
+ public float getFloat(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, float value) {
return DataAuthorizationContext.getInstance().columnAuthorization(interceptState,tableName, columnName, value);
}
@Override
- public double getDouble(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, double value) {
+ public double getDouble(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, double value) {
return DataAuthorizationContext.getInstance().columnAuthorization(interceptState,tableName, columnName, value);
}
@Override
- public BigDecimal getBigDecimal(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, BigDecimal value) {
+ public BigDecimal getBigDecimal(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, BigDecimal value) {
return DataAuthorizationContext.getInstance().columnAuthorization(interceptState,tableName, columnName, value);
}
@Override
- public byte[] getBytes(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, byte[] value) {
+ public byte[] getBytes(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, byte[] value) {
return DataAuthorizationContext.getInstance().columnAuthorization(interceptState,tableName, columnName, value);
}
@Override
- public Date getDate(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, Date value) {
+ public Date getDate(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, Date value) {
return DataAuthorizationContext.getInstance().columnAuthorization(interceptState,tableName, columnName, value);
}
@Override
- public Time getTime(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, Time value) {
+ public Time getTime(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, Time value) {
return DataAuthorizationContext.getInstance().columnAuthorization(interceptState,tableName, columnName, value);
}
@Override
- public Timestamp getTimestamp(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, Timestamp value) {
+ public Timestamp getTimestamp(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, Timestamp value) {
return DataAuthorizationContext.getInstance().columnAuthorization(interceptState,tableName, columnName, value);
}
@Override
- public InputStream getAsciiStream(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, InputStream value) {
+ public InputStream getAsciiStream(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, InputStream value) {
return DataAuthorizationContext.getInstance().columnAuthorization(interceptState,tableName, columnName, value);
}
@Override
- public InputStream getUnicodeStream(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, InputStream value) {
+ public InputStream getUnicodeStream(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, InputStream value) {
return DataAuthorizationContext.getInstance().columnAuthorization(interceptState,tableName, columnName, value);
}
@Override
- public InputStream getBinaryStream(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, InputStream value) {
+ public InputStream getBinaryStream(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, InputStream value) {
return DataAuthorizationContext.getInstance().columnAuthorization(interceptState,tableName, columnName, value);
}
@Override
- public Object getObject(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, Object value) {
+ public Object getObject(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, Object value) {
return DataAuthorizationContext.getInstance().columnAuthorization(interceptState,tableName, columnName, value);
}
@Override
- public Reader getCharacterStream(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, Reader value) {
+ public Reader getCharacterStream(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, Reader value) {
return DataAuthorizationContext.getInstance().columnAuthorization(interceptState,tableName, columnName, value);
}
@Override
- public Ref getRef(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, Ref value) {
+ public Ref getRef(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, Ref value) {
return DataAuthorizationContext.getInstance().columnAuthorization(interceptState,tableName, columnName, value);
}
@Override
- public Blob getBlob(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, Blob value) {
+ public Blob getBlob(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, Blob value) {
return DataAuthorizationContext.getInstance().columnAuthorization(interceptState,tableName, columnName, value);
}
@Override
- public Clob getClob(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, Clob value) {
+ public Clob getClob(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, Clob value) {
return DataAuthorizationContext.getInstance().columnAuthorization(interceptState,tableName, columnName, value);
}
@Override
- public Array getArray(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, Array value) {
+ public Array getArray(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, Array value) {
return DataAuthorizationContext.getInstance().columnAuthorization(interceptState,tableName, columnName, value);
}
@Override
- public URL getURL(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, URL value) {
+ public URL getURL(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, URL value) {
return DataAuthorizationContext.getInstance().columnAuthorization(interceptState,tableName, columnName, value);
}
@Override
- public NClob getNClob(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, NClob value) {
+ public NClob getNClob(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, NClob value) {
return DataAuthorizationContext.getInstance().columnAuthorization(interceptState,tableName, columnName, value);
}
@Override
- public SQLXML getSQLXML(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, SQLXML value) {
+ public SQLXML getSQLXML(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, SQLXML value) {
return DataAuthorizationContext.getInstance().columnAuthorization(interceptState,tableName, columnName, value);
}
@Override
- public String getNString(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, String value) {
+ public String getNString(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, String value) {
return DataAuthorizationContext.getInstance().columnAuthorization(interceptState,tableName, columnName, value);
}
@Override
- public Reader getNCharacterStream(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, Reader value) {
+ public Reader getNCharacterStream(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, Reader value) {
return DataAuthorizationContext.getInstance().columnAuthorization(interceptState,tableName, columnName, value);
}
@Override
- public RowId getRowId(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, RowId value) {
+ public RowId getRowId(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, RowId value) {
return DataAuthorizationContext.getInstance().columnAuthorization(interceptState,tableName, columnName, value);
}
@Override
- public T getObject(SQLInterceptState interceptState, int columnIndex, String tableName, String columnName, T value, Class type) {
+ public T getObject(SQLExecuteState interceptState, int columnIndex, String tableName, String columnName, T value, Class type) {
return DataAuthorizationContext.getInstance().columnAuthorization(interceptState,tableName, columnName, value);
}
}
diff --git a/springboot-starter-data-authorization/src/main/java/com/codingapi/springboot/authorization/interceptor/SQLInterceptState.java b/springboot-starter-data-authorization/src/main/java/com/codingapi/springboot/authorization/interceptor/SQLExecuteState.java
similarity index 55%
rename from springboot-starter-data-authorization/src/main/java/com/codingapi/springboot/authorization/interceptor/SQLInterceptState.java
rename to springboot-starter-data-authorization/src/main/java/com/codingapi/springboot/authorization/interceptor/SQLExecuteState.java
index 809668fba..96900c82b 100644
--- a/springboot-starter-data-authorization/src/main/java/com/codingapi/springboot/authorization/interceptor/SQLInterceptState.java
+++ b/springboot-starter-data-authorization/src/main/java/com/codingapi/springboot/authorization/interceptor/SQLExecuteState.java
@@ -5,18 +5,30 @@
/**
* SQL拦截状态
*/
-public class SQLInterceptState {
+public class SQLExecuteState {
- private final boolean state;
+ /**
+ * 是否拦截SQL
+ */
+ private final boolean intercept;
+ /**
+ * 原始SQL
+ */
private final String sql;
+ /**
+ * 处理后的SQL
+ */
private final String newSql;
+ /**
+ * 表字段别名对象
+ */
private final TableColumnAliasContext aliasContext;
- private SQLInterceptState(boolean state, String sql, String newSql, TableColumnAliasContext aliasContext) {
- this.state = state;
+ private SQLExecuteState(boolean intercept, String sql, String newSql, TableColumnAliasContext aliasContext) {
+ this.intercept = intercept;
this.sql = sql;
this.newSql = newSql;
this.aliasContext = aliasContext;
@@ -25,15 +37,15 @@ private SQLInterceptState(boolean state, String sql, String newSql, TableColumnA
/**
* 拦截
*/
- public static SQLInterceptState intercept(String sql, String newSql, TableColumnAliasContext aliasContext) {
- return new SQLInterceptState(true, sql, newSql, aliasContext);
+ public static SQLExecuteState intercept(String sql, String newSql, TableColumnAliasContext aliasContext) {
+ return new SQLExecuteState(true, sql, newSql, aliasContext);
}
/**
* 不拦截
*/
- public static SQLInterceptState unIntercept(String sql) {
- return new SQLInterceptState(false, sql, sql, null);
+ public static SQLExecuteState unIntercept(String sql) {
+ return new SQLExecuteState(false, sql, sql, null);
}
public String getTableName(String tableName) {
@@ -45,7 +57,7 @@ public String getColumnName(String tableName, String columnName) {
}
public String getSql() {
- if (state) {
+ if (intercept) {
return newSql;
} else {
return sql;
@@ -53,7 +65,7 @@ public String getSql() {
}
public boolean hasIntercept() {
- return state;
+ return intercept;
}
diff --git a/springboot-starter-data-authorization/src/main/java/com/codingapi/springboot/authorization/interceptor/SQLRunningContext.java b/springboot-starter-data-authorization/src/main/java/com/codingapi/springboot/authorization/interceptor/SQLRunningContext.java
index c22d4e259..d23bb4cf7 100644
--- a/springboot-starter-data-authorization/src/main/java/com/codingapi/springboot/authorization/interceptor/SQLRunningContext.java
+++ b/springboot-starter-data-authorization/src/main/java/com/codingapi/springboot/authorization/interceptor/SQLRunningContext.java
@@ -1,5 +1,6 @@
package com.codingapi.springboot.authorization.interceptor;
+import com.codingapi.springboot.authorization.DataAuthorizationContext;
import lombok.Getter;
import java.sql.SQLException;
@@ -25,11 +26,12 @@ private SQLRunningContext() {
* @return SQLInterceptState
* @throws SQLException SQLException
*/
- public SQLInterceptState intercept(String sql) throws SQLException {
+ public SQLExecuteState intercept(String sql) throws SQLException {
SQLInterceptor sqlInterceptor = SQLInterceptorContext.getInstance().getSqlInterceptor();
if (skipInterceptor.get()) {
- return SQLInterceptState.unIntercept(sql);
+ sql = DataAuthorizationContext.getInstance().skipSQLFilter(sql);
+ return SQLExecuteState.unIntercept(sql);
}
try {
if (sqlInterceptor.beforeHandler(sql)) {
@@ -37,7 +39,7 @@ public SQLInterceptState intercept(String sql) throws SQLException {
skipInterceptor.set(true);
DataPermissionSQL dataPermissionSQL = sqlInterceptor.postHandler(sql);
sqlInterceptor.afterHandler(sql, dataPermissionSQL.getNewSql(), null);
- return SQLInterceptState.intercept(sql, dataPermissionSQL.getNewSql(), dataPermissionSQL.getAliasContext());
+ return SQLExecuteState.intercept(sql, dataPermissionSQL.getNewSql(), dataPermissionSQL.getAliasContext());
}
} catch (SQLException exception) {
sqlInterceptor.afterHandler(sql, null, exception);
@@ -45,7 +47,7 @@ public SQLInterceptState intercept(String sql) throws SQLException {
// 重置拦截器状态
skipInterceptor.set(false);
}
- return SQLInterceptState.unIntercept(sql);
+ return SQLExecuteState.unIntercept(sql);
}
diff --git a/springboot-starter-data-authorization/src/main/java/com/codingapi/springboot/authorization/jdbc/proxy/CallableStatementProxy.java b/springboot-starter-data-authorization/src/main/java/com/codingapi/springboot/authorization/jdbc/proxy/CallableStatementProxy.java
index 40f9a51e0..b2e3e99b2 100644
--- a/springboot-starter-data-authorization/src/main/java/com/codingapi/springboot/authorization/jdbc/proxy/CallableStatementProxy.java
+++ b/springboot-starter-data-authorization/src/main/java/com/codingapi/springboot/authorization/jdbc/proxy/CallableStatementProxy.java
@@ -1,6 +1,6 @@
package com.codingapi.springboot.authorization.jdbc.proxy;
-import com.codingapi.springboot.authorization.interceptor.SQLInterceptState;
+import com.codingapi.springboot.authorization.interceptor.SQLExecuteState;
import com.codingapi.springboot.authorization.interceptor.SQLRunningContext;
import lombok.AllArgsConstructor;
@@ -17,7 +17,7 @@ public class CallableStatementProxy implements CallableStatement {
private final CallableStatement callableStatement;
- private SQLInterceptState interceptState;
+ private SQLExecuteState interceptState;
@Override
public void registerOutParameter(int parameterIndex, int sqlType) throws SQLException {
diff --git a/springboot-starter-data-authorization/src/main/java/com/codingapi/springboot/authorization/jdbc/proxy/ConnectionProxy.java b/springboot-starter-data-authorization/src/main/java/com/codingapi/springboot/authorization/jdbc/proxy/ConnectionProxy.java
index 33697a230..88f10ec41 100644
--- a/springboot-starter-data-authorization/src/main/java/com/codingapi/springboot/authorization/jdbc/proxy/ConnectionProxy.java
+++ b/springboot-starter-data-authorization/src/main/java/com/codingapi/springboot/authorization/jdbc/proxy/ConnectionProxy.java
@@ -1,6 +1,6 @@
package com.codingapi.springboot.authorization.jdbc.proxy;
-import com.codingapi.springboot.authorization.interceptor.SQLInterceptState;
+import com.codingapi.springboot.authorization.interceptor.SQLExecuteState;
import com.codingapi.springboot.authorization.interceptor.SQLRunningContext;
import java.sql.*;
@@ -16,7 +16,7 @@ public ConnectionProxy(Connection connection) {
this.connection = connection;
}
- private SQLInterceptState interceptState;
+ private SQLExecuteState interceptState;
@Override
public Statement createStatement() throws SQLException {
diff --git a/springboot-starter-data-authorization/src/main/java/com/codingapi/springboot/authorization/jdbc/proxy/PreparedStatementProxy.java b/springboot-starter-data-authorization/src/main/java/com/codingapi/springboot/authorization/jdbc/proxy/PreparedStatementProxy.java
index 65d738772..06dfed919 100644
--- a/springboot-starter-data-authorization/src/main/java/com/codingapi/springboot/authorization/jdbc/proxy/PreparedStatementProxy.java
+++ b/springboot-starter-data-authorization/src/main/java/com/codingapi/springboot/authorization/jdbc/proxy/PreparedStatementProxy.java
@@ -1,6 +1,6 @@
package com.codingapi.springboot.authorization.jdbc.proxy;
-import com.codingapi.springboot.authorization.interceptor.SQLInterceptState;
+import com.codingapi.springboot.authorization.interceptor.SQLExecuteState;
import com.codingapi.springboot.authorization.interceptor.SQLRunningContext;
import lombok.AllArgsConstructor;
@@ -16,7 +16,7 @@ public class PreparedStatementProxy implements PreparedStatement {
private final PreparedStatement preparedStatement;
- private SQLInterceptState interceptState;
+ private SQLExecuteState interceptState;
@Override
diff --git a/springboot-starter-data-authorization/src/main/java/com/codingapi/springboot/authorization/jdbc/proxy/ResultSetProxy.java b/springboot-starter-data-authorization/src/main/java/com/codingapi/springboot/authorization/jdbc/proxy/ResultSetProxy.java
index e3df119d1..74cd61afd 100644
--- a/springboot-starter-data-authorization/src/main/java/com/codingapi/springboot/authorization/jdbc/proxy/ResultSetProxy.java
+++ b/springboot-starter-data-authorization/src/main/java/com/codingapi/springboot/authorization/jdbc/proxy/ResultSetProxy.java
@@ -1,7 +1,7 @@
package com.codingapi.springboot.authorization.jdbc.proxy;
import com.codingapi.springboot.authorization.handler.ColumnHandlerContext;
-import com.codingapi.springboot.authorization.interceptor.SQLInterceptState;
+import com.codingapi.springboot.authorization.interceptor.SQLExecuteState;
import lombok.extern.slf4j.Slf4j;
import java.io.InputStream;
@@ -18,11 +18,11 @@ public class ResultSetProxy implements ResultSet {
private final ResultSet resultSet;
private final ResultSetMetaData metaData;
- private final SQLInterceptState interceptState;
+ private final SQLExecuteState interceptState;
private final Map columnLabelMap = new HashMap<>();
- public ResultSetProxy(ResultSet resultSet, SQLInterceptState interceptState) throws SQLException {
+ public ResultSetProxy(ResultSet resultSet, SQLExecuteState interceptState) throws SQLException {
this.resultSet = resultSet;
this.metaData = resultSet.getMetaData();
this.interceptState = interceptState;
diff --git a/springboot-starter-data-authorization/src/main/java/com/codingapi/springboot/authorization/jdbc/proxy/StatementProxy.java b/springboot-starter-data-authorization/src/main/java/com/codingapi/springboot/authorization/jdbc/proxy/StatementProxy.java
index 278a87a0d..99a0a46bf 100644
--- a/springboot-starter-data-authorization/src/main/java/com/codingapi/springboot/authorization/jdbc/proxy/StatementProxy.java
+++ b/springboot-starter-data-authorization/src/main/java/com/codingapi/springboot/authorization/jdbc/proxy/StatementProxy.java
@@ -1,6 +1,6 @@
package com.codingapi.springboot.authorization.jdbc.proxy;
-import com.codingapi.springboot.authorization.interceptor.SQLInterceptState;
+import com.codingapi.springboot.authorization.interceptor.SQLExecuteState;
import com.codingapi.springboot.authorization.interceptor.SQLRunningContext;
import lombok.AllArgsConstructor;
@@ -10,7 +10,7 @@
public class StatementProxy implements Statement {
private final Statement statement;
- private SQLInterceptState interceptState;
+ private SQLExecuteState interceptState;
diff --git a/springboot-starter-data-authorization/src/test/java/com/codingapi/springboot/authorization/DataAuthorizationContextTest.java b/springboot-starter-data-authorization/src/test/java/com/codingapi/springboot/authorization/DataAuthorizationContextTest.java
index d6e1f7071..581836884 100644
--- a/springboot-starter-data-authorization/src/test/java/com/codingapi/springboot/authorization/DataAuthorizationContextTest.java
+++ b/springboot-starter-data-authorization/src/test/java/com/codingapi/springboot/authorization/DataAuthorizationContextTest.java
@@ -1,11 +1,15 @@
package com.codingapi.springboot.authorization;
import com.codingapi.springboot.authorization.current.CurrentUser;
+import com.codingapi.springboot.authorization.enhancer.DataPermissionSQLEnhancer;
import com.codingapi.springboot.authorization.entity.Depart;
import com.codingapi.springboot.authorization.entity.Unit;
import com.codingapi.springboot.authorization.entity.User;
+import com.codingapi.springboot.authorization.filter.DataAuthorizationFilter;
import com.codingapi.springboot.authorization.filter.DefaultDataAuthorizationFilter;
+import com.codingapi.springboot.authorization.filter.SkipAuthorizationFilter;
import com.codingapi.springboot.authorization.handler.Condition;
+import com.codingapi.springboot.authorization.handler.RowHandler;
import com.codingapi.springboot.authorization.interceptor.SQLRunningContext;
import com.codingapi.springboot.authorization.mask.ColumnMaskContext;
import com.codingapi.springboot.authorization.mask.impl.BankCardMask;
@@ -337,4 +341,53 @@ public boolean supportRowAuthorization(String tableName, String tableAlias) {
}
+
+
+ @Test
+ @Order(5)
+ void test5() throws Exception{
+
+ unitRepository.deleteAll();
+ departRepository.deleteAll();
+ userRepository.deleteAll();
+
+ Unit rootUnit = new Unit("Coding总公司");
+ unitRepository.save(rootUnit);
+
+ Unit sdUnit = new Unit("Coding山东分公司", rootUnit.getId());
+ unitRepository.save(sdUnit);
+
+ Depart jgbDepart = new Depart("Coding架构部", rootUnit.getId());
+ departRepository.save(jgbDepart);
+
+ Depart xmbDepart = new Depart("Coding项目部", sdUnit.getId());
+ departRepository.save(xmbDepart);
+
+ User lorne = new User("lorne", LocalDate.parse("1991-01-01"), "beijing", "110105199003078999", "13812345678", jgbDepart);
+ User bob = new User("bob", LocalDate.parse("1991-01-01"), "beijing", "110105199003078999", "13812345678", xmbDepart);
+ User tom = new User("tom", LocalDate.parse("1991-01-01"), "beijing", "110105199003078999", "13812345678", xmbDepart);
+
+ userRepository.save(lorne);
+ userRepository.save(bob);
+ userRepository.save(tom);
+
+ String sql = "select * from t_user where phone like '%1%' and id > 1 and depart_id in (select id from t_depart where id > 0) ";
+
+ DataAuthorizationContext.getInstance().clearDataAuthorizationFilters();
+
+ DataAuthorizationContext.getInstance().setSkipAuthorizationFilter(new SkipAuthorizationFilter(){
+ @Override
+ public String filter(String sql) {
+ return sql.replace("and depart_id in (select id from t_depart where id > 0) ","");
+ }
+ });
+
+ SQLRunningContext.getInstance().skipDataAuthorization(()->{
+ List