| | |
| | | import org.apache.ibatis.reflection.MetaObject; |
| | | import org.apache.ibatis.reflection.SystemMetaObject; |
| | | import org.apache.ibatis.session.Configuration; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.lang.reflect.Field; |
| | |
| | | }) |
| | | }) |
| | | public class MySqlInterceptor implements Interceptor { |
| | | |
| | | private static Logger logger = LoggerFactory.getLogger(MySqlInterceptor.class.getName()); |
| | | @Override |
| | | public Object intercept(Invocation invocation) throws Throwable { |
| | | |
| | |
| | | //这里可以进行sql修改 |
| | | //获取到原始sql语句 |
| | | String sql = boundSql.getSql(); |
| | | |
| | | //新增 |
| | | if(sqlCommandType == SqlCommandType.INSERT){ |
| | | sql = SqlUtils.insertSql(sql, VariableAesKey.aesKeysTable); |
| | |
| | | sql = SqlUtils.deleteSql(sql, VariableAesKey.aesKeysTable); |
| | | } |
| | | |
| | | |
| | | |
| | | if(!"err".equals(sql)){ |
| | | //通过反射修改sql语句 |
| | | Field field = boundSql.getClass().getDeclaredField("sql"); |
| | | field.setAccessible(true); |
| | | field.set(boundSql, sql); |
| | | } |
| | | //通过反射修改sql语句 |
| | | Field field = boundSql.getClass().getDeclaredField("sql"); |
| | | field.setAccessible(true); |
| | | field.set(boundSql, sql); |
| | | |
| | | return invocation.proceed(); |
| | | |