@@ -2589,7 +2589,7 @@ else if (id instanceof Subquery) {}
2589
2589
String [] ws = StringUtil .split (combine );
2590
2590
if (ws != null ) {
2591
2591
if (method == DELETE || method == GETS || method == HEADS ) {
2592
- throw new IllegalArgumentException ("DELETE,GETS,HEADS 请求不允许传 @combine:\" conditons \" !" );
2592
+ throw new IllegalArgumentException ("DELETE,GETS,HEADS 请求不允许传 @combine:value !" );
2593
2593
}
2594
2594
whereList = new ArrayList <>();
2595
2595
@@ -2633,8 +2633,11 @@ else if (w.startsWith("!")) {
2633
2633
2634
2634
whereList .add (w );
2635
2635
}
2636
- if (request .containsKey (w ) == false ) {
2637
- throw new IllegalArgumentException (table + ":{} 里的 @combine:value 中的value里 " + ws [i ] + " 对应的 " + w + " 不在它里面!" );
2636
+
2637
+ // 可重写回调方法自定义处理 // 动态设置的场景似乎很少,而且去掉后不方便用户排错!//去掉判断,有时候不在没关系,如果是对增删改等非开放请求强制要求传对应的条件,可以用 Operation.NECESSARY
2638
+ if (request .containsKey (w ) == false ) { //和 request.get(w) == null 没区别,前面 Parser 已经过滤了 null
2639
+ // throw new IllegalArgumentException(table + ":{} 里的 @combine:value 中的value里 " + ws[i] + " 对应的 " + w + " 不在它里面!");
2640
+ callback .onMissingKey4Combine (table , request , combine , ws [i ], w );
2638
2641
}
2639
2642
}
2640
2643
@@ -2931,7 +2934,6 @@ public static interface Callback {
2931
2934
*/
2932
2935
SQLConfig getSQLConfig (RequestMethod method , String database , String schema , String table );
2933
2936
2934
-
2935
2937
/**为 post 请求新建 id, 只能是 Long 或 String
2936
2938
* @param method
2937
2939
* @param database
@@ -2956,6 +2958,13 @@ public static interface Callback {
2956
2958
* @return
2957
2959
*/
2958
2960
String getUserIdKey (String database , String schema , String table );
2961
+
2962
+ /**combine 里的 key 在 request 中 value 为 null 或不存在,即 request 中缺少用来作为 combine 条件的 key: value
2963
+ * @param combine
2964
+ * @param key
2965
+ * @param request
2966
+ */
2967
+ public void onMissingKey4Combine (String name , JSONObject request , String combine , String item , String key ) throws Exception ;
2959
2968
}
2960
2969
2961
2970
public static abstract class SimpleCallback implements Callback {
@@ -2975,6 +2984,11 @@ public String getIdKey(String database, String schema, String table) {
2975
2984
public String getUserIdKey (String database , String schema , String table ) {
2976
2985
return KEY_USER_ID ;
2977
2986
}
2987
+
2988
+ @ Override
2989
+ public void onMissingKey4Combine (String name , JSONObject request , String combine , String item , String key ) throws Exception {
2990
+ throw new IllegalArgumentException (name + ":{} 里的 @combine:value 中的value里 " + item + " 对应的条件 " + key + ":value 中 value 不能为 null!" );
2991
+ }
2978
2992
2979
2993
}
2980
2994
0 commit comments