This commit is contained in:
wulin 2020-12-28 14:30:38 +08:00
commit 6a6de252b5

View File

@ -63,11 +63,12 @@ public class DataScopeInterceptor extends AbstractSqlParserHandler implements In
String originalSql = boundSql.getSql();
Object parameterObject = boundSql.getParameterObject();
MappedStatement mappedStatement = (MappedStatement) metaObject.getValue("delegate.mappedStatement");
String sqlCommandTypePre = "SELECT SQL = ";
String mapperdId = getMapperId(mappedStatement);
String sqlCommandTypePre = "SELECT SQL = " + mapperdId + " ";
if(SqlCommandType.INSERT.equals(mappedStatement.getSqlCommandType())){
sqlCommandTypePre = "INSERT SQL = ";
sqlCommandTypePre = "INSERT SQL = " + mapperdId + " ";
}else if (SqlCommandType.UPDATE.equals(mappedStatement.getSqlCommandType())){
sqlCommandTypePre = "UPDATE SQL = ";
sqlCommandTypePre = "UPDATE SQL = " + mapperdId + " ";
}
Configuration configuration = mappedStatement.getConfiguration();
@ -170,6 +171,26 @@ public class DataScopeInterceptor extends AbstractSqlParserHandler implements In
}
public static String getMapperId(MappedStatement mappedStatement) {
try {
String id = mappedStatement.getId();
if(id.contains(".")){
String ids []= id.split("\\.");
return ids[ids.length -2 ] +"."+ ids[ids.length -1 ];
}
return null;
} catch (Exception e) {
e.printStackTrace();
} finally {
}
return "";
}
public static void main(String[] args) {
}
/**
* 查找参数是否包括DataScope对象
*