瀏覽代碼

1、修改selectbyid切面方法

zhoux 2 年之前
父節點
當前提交
d4dce9af2b

+ 2 - 2
src/main/java/com/dk/common/infrastructure/aspect/ServiceAspect.java

@@ -117,8 +117,8 @@ public class ServiceAspect implements HandlerInterceptor {
 //            //调用方法
 //            //调用方法
 //            String primaryKey = (String) m.invoke(obj);
 //            String primaryKey = (String) m.invoke(obj);
 
 
-            /* 从请求头中获取主键Id,用于用Id进行查询的是否加入语言和公司 */
-            MybatisSqlIntercept.primaryKey = httpServletRequest.getHeader("primaryKey");
+//            /* 从请求头中获取主键Id,用于用Id进行查询的是否加入语言和公司 */
+//            MybatisSqlIntercept.primaryKey = httpServletRequest.getHeader("primaryKey");
             /* 从请求头中获取国际化参数 */
             /* 从请求头中获取国际化参数 */
             MybatisSqlIntercept.I18N = httpServletRequest.getHeader("i18n");
             MybatisSqlIntercept.I18N = httpServletRequest.getHeader("i18n");
 
 

+ 21 - 13
src/main/java/com/dk/common/infrastructure/util/MybatisSqlIntercept.java

@@ -42,7 +42,7 @@ public class MybatisSqlIntercept implements Interceptor {
 
 
     public static String I18N = "";
     public static String I18N = "";
     public static Integer cpId = 0;
     public static Integer cpId = 0;
-    public static String primaryKey = null;
+//    public static String primaryKey = null;
 
 
     @Override
     @Override
     public Object intercept(Invocation invocation) throws Throwable {
     public Object intercept(Invocation invocation) throws Throwable {
@@ -67,24 +67,32 @@ public class MybatisSqlIntercept implements Interceptor {
             }
             }
             if (argsNo2Map != null) {
             if (argsNo2Map != null) {
                 argsNo2Map.put("i18n", I18N);
                 argsNo2Map.put("i18n", I18N);
-                if(cpId != 0){
+                if (cpId != 0) {
                     argsNo2Map.put("cpId", cpId);
                     argsNo2Map.put("cpId", cpId);
                 }
                 }
                 args2[1] = argsNo2Map;
                 args2[1] = argsNo2Map;
             }
             }
         } else {
         } else {
-            if(primaryKey != null ){
-                Map<String, Object> argsNo2Map = new HashMap<>();
-                // 默认叫id
-                argsNo2Map.put(primaryKey,args[1]);
-                argsNo2Map.put("i18n", I18N);
-                if(cpId != 0){
-                    argsNo2Map.put("cpId", cpId);
-                }
-                args2[1] =argsNo2Map;
-            }else{
-                args2[1] = args[1];
+            Map<String, Object> argsNo2Map = new HashMap<>();
+            // 默认叫id
+            argsNo2Map.put("id", args[1]);
+            argsNo2Map.put("i18n", I18N);
+            if (cpId != 0) {
+                argsNo2Map.put("cpId", cpId);
             }
             }
+            args2[1] = argsNo2Map;
+//            if(primaryKey != null ){
+//                Map<String, Object> argsNo2Map = new HashMap<>();
+//                // 默认叫id
+//                argsNo2Map.put(primaryKey,args[1]);
+//                argsNo2Map.put("i18n", I18N);
+//                if(cpId != 0){
+//                    argsNo2Map.put("cpId", cpId);
+//                }
+//                args2[1] =argsNo2Map;
+//            }else{
+//                args2[1] = args[1];
+//            }
             //TODO 在此添加单参数的逻辑 做法是获取父类的方法的参数名 然后把单参数转成Map传给xml
             //TODO 在此添加单参数的逻辑 做法是获取父类的方法的参数名 然后把单参数转成Map传给xml
         }
         }
         args2[0] = args[0];
         args2[0] = args[0];