@@ -3012,9 +3012,20 @@ protected String parseCombineExpression(RequestMethod method, String quote, Stri
3012
3012
}
3013
3013
3014
3014
String column = key ;
3015
- int keyIndex = column .indexOf (":" );
3016
- column = keyIndex > 0 ? column .substring (0 , keyIndex ) : column ;
3017
- Object value = conditionMap .get (column );
3015
+ int keyIndex = column .indexOf (":" );
3016
+ Object value = null ;
3017
+ //combine增加数据筛选,兼容combine与data中存在同字段,可用combine筛选后再通过data覆盖字段数据
3018
+ if (keyIndex > -1 ) {
3019
+ String valueKey = key .substring (keyIndex );
3020
+ if (valueKey != null && valueKey .indexOf ("=" ) > -1 ) {
3021
+ int valueKeyIndex = valueKey .indexOf ("=" );
3022
+ value = valueKey .substring (valueKeyIndex + 1 );
3023
+ }
3024
+ }
3025
+ column = keyIndex > 0 ? column .substring (0 , keyIndex ) : column ;
3026
+ if (value == null ) {
3027
+ value = conditionMap .get (column );
3028
+ }
3018
3029
String wi = "" ;
3019
3030
if (value == null && conditionMap .containsKey (column ) == false ) { // 兼容@null
3020
3031
isNot = false ; // 以占位表达式为准
@@ -5471,16 +5482,28 @@ else if (w.startsWith("!")) {
5471
5482
}
5472
5483
5473
5484
// 兼容 PUT @combine
5474
- // 解决AccessVerifier新增userId没有作为条件,而是作为内容,导致PUT,DELETE出错
5475
- if ((isWhere || (StringUtil .isName (key .replaceFirst ("[+-]$" , "" )) == false ))
5476
- || (isWhere == false && StringUtil .isNotEmpty (combineExpr , true ) && isKeyInCombineExpr (combineExpr , key ))) {
5485
+ // 解决AccessVerifier新增userId没有作为条件,而是作为内容,导致PUT,DELETE出错
5486
+ //if ((isWhere || (StringUtil.isName(key.replaceFirst("[+-]$", "")) == false)) || (isWhere == false && StringUtil.isNotEmpty(combineExpr, true) && isKeyInCombineExpr(combineExpr, key))) {
5487
+ //tableWhere.put(key, value);
5488
+ //if (whereList.contains(key) == false) {
5489
+ //andList.add(key);
5490
+ //}
5491
+ //} else if (whereList.contains(key)) {
5492
+ // tableWhere.put(key, value);
5493
+ //} else {
5494
+ // tableContent.put(key, value); // 一样 instanceof JSONArray ? JSON.toJSONString(value) : value);
5495
+ //}
5496
+ //不限制combine内的key只能作为条件,可使用table:{"a":"1","@combine":"a:a=3331"}的方式对a=3331的数据修改为a=1。同时兼容旧的combine格式
5497
+ if ((isWhere || (StringUtil .isName (key .replaceFirst ("[+-]$" , "" )) == false )) || (isWhere == false && StringUtil .isNotEmpty (combineExpr , true )) && isKeyInCombineExpr (combineExpr , key )) {
5477
5498
tableWhere .put (key , value );
5478
5499
if (whereList .contains (key ) == false ) {
5479
5500
andList .add (key );
5480
5501
}
5481
5502
} else if (whereList .contains (key )) {
5482
5503
tableWhere .put (key , value );
5483
- } else {
5504
+ }
5505
+ //当combine只有单个key没有数据时,将数据内容转成条件。当combine有key=value时,对数据内容进行修改
5506
+ if (!key .equals (combineExpr )) {
5484
5507
tableContent .put (key , value ); // 一样 instanceof JSONArray ? JSON.toJSONString(value) : value);
5485
5508
}
5486
5509
}
0 commit comments