Ver código fonte

测试拦截器

kouchengxing 5 anos atrás
pai
commit
8ec0cb9526

+ 2 - 0
dgtly-apiframework/src/main/java/com/dgtly/apiframework/config/SwitchEnSqlInterceptorConfig.java

@@ -28,12 +28,14 @@ public class SwitchEnSqlInterceptorConfig {
 
         @PostConstruct
         public void addPageInterceptor() {
+            System.out.println("进入拦截器配置SwitchEnSqlInterceptorConfig-------------------------------------------------");
             SwitchEnSqlInterceptor interceptor = new SwitchEnSqlInterceptor();
             Iterator var3 = this.sqlSessionFactoryList.iterator();
             Properties properties = new Properties();
             interceptor.setProperties( properties);
             while(var3.hasNext()) {
                 SqlSessionFactory sqlSessionFactory = (SqlSessionFactory)var3.next();
+                System.out.println("加入拦截器到配置------------------------------------------------------------------------");
                 sqlSessionFactory.getConfiguration().addInterceptor(interceptor);
             }
 

+ 2 - 1
dgtly-apiframework/src/main/java/com/dgtly/apiframework/interceptor/SwitchEnSqlInterceptor.java

@@ -34,6 +34,7 @@ public class SwitchEnSqlInterceptor  implements Interceptor {
     }
 
     public Object intercept(Invocation invocation) throws Throwable {
+        System.out.println("进入拦截器----------------------------------------------");
         // 获取原始sql语句
         MappedStatement mappedStatement = (MappedStatement) invocation.getArgs()[0];
         Object parameter = invocation.getArgs()[1];
@@ -46,13 +47,13 @@ public class SwitchEnSqlInterceptor  implements Interceptor {
         String language = request.getHeader("language");
 
         if(StringUtils.isNotEmpty(language) && "en".equalsIgnoreCase(language)){
-
             // 方法中含有获取注解
             Class<?> classType = Class.forName(mappedStatement.getId().substring(0,mappedStatement.getId().lastIndexOf(".")));
             String mName  = mappedStatement.getId().substring(mappedStatement.getId().lastIndexOf(".") + 1 ,mappedStatement.getId().length());
             for(Method method : classType.getDeclaredMethods()){
                 if(method!=null && mName.equals(method.getName()) && method.isAnnotationPresent(SwitchEn.class))
                 {
+                    System.out.println("处理boundSql------------------------------------");
                     SwitchEn switchEn = method.getAnnotation(SwitchEn.class);
                     String[] oldfiles = switchEn.oldfiles();
                     String[] newfiles = switchEn.newfiles();