@@ -531,7 +531,7 @@ public static String getWhereString(RequestMethod method, Map<String, Object> wh
531531 continue ;
532532 }
533533
534- whereString += (isFirst ? "" : AND ) + condition ;
534+ whereString += (isFirst ? "" : AND ) + "(" + condition + ")" ;
535535
536536 isFirst = false ;
537537 }
@@ -639,7 +639,7 @@ public static String getSearchString(String key, Object[] values, int type) thro
639639 condition += (i <= 0 ? "" : (Logic .isAnd (type ) ? AND : OR )) + getLikeString (key , values [i ]);
640640 }
641641
642- return (Logic .isNot (type ) ? NOT : "" ) + "(" + condition + ")" ;
642+ return getCondition (Logic .isNot (type ), condition ) ;
643643 }
644644
645645 /**WHERE key LIKE 'value'
@@ -693,7 +693,7 @@ public static String getRegExpString(String key, Object[] values, int type) thro
693693 condition += (i <= 0 ? "" : (Logic .isAnd (type ) ? AND : OR )) + getRegExpString (key , (String ) values [i ]);
694694 }
695695
696- return (Logic .isNot (type ) ? NOT : "" ) + "(" + condition + ")" ;
696+ return getCondition (Logic .isNot (type ), condition ) ;
697697 }
698698
699699 /**WHERE key REGEXP 'value'
@@ -747,8 +747,7 @@ public static String getRangeString(String key, Object range) throws Exception {
747747 if (condition .isEmpty ()) {
748748 return "" ;
749749 }
750- condition = "(" + condition + ")" ;
751- return logic .isNot () ? NOT + condition : condition ;
750+ return getCondition (logic .isNot (), condition );
752751 }
753752
754753 throw new IllegalArgumentException (key + "{}:range 类型为" + range .getClass ().getSimpleName ()
@@ -770,7 +769,7 @@ public static String getInString(String key, Object[] in, boolean not) throws No
770769 throw new NotExistException (TAG + ".getInString(" + key + ", [], " + not
771770 + ") >> condition.isEmpty() >> IN()" );
772771 }
773- return (not ? NOT : "" ) + " IN " + " (" + condition + ")" ;
772+ return (not ? NOT : "" ) + " IN (" + condition + ")" ;
774773 }
775774 //{} range >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
776775
@@ -814,7 +813,7 @@ public static String getContainString(String key, Object[] childs, int type) thr
814813 childs [i ] = "\" " + childs [i ] + "\" " ;
815814 }
816815 condition += (i <= 0 ? "" : (Logic .isAnd (type ) ? AND : OR ))
817- + getSearchString (
816+ + "(" + getSearchString (
818817 key
819818 , new String []{
820819 "[" + childs [i ] + "]" , //全等
@@ -823,7 +822,7 @@ public static String getContainString(String key, Object[] childs, int type) thr
823822 "%, " + childs [i ] + "]" //末尾
824823 }
825824 , Logic .TYPE_OR
826- );
825+ ) + ")" ;
827826 }
828827 }
829828 if (condition .isEmpty ()) {
@@ -833,10 +832,19 @@ public static String getContainString(String key, Object[] childs, int type) thr
833832 if (condition .isEmpty ()) {
834833 return "" ;
835834 }
836- return (Logic .isNot (type ) ? NOT : "" ) + "(" + condition + ")" ;
835+ return getCondition (Logic .isNot (type ), condition ) ;
837836 }
838837 //<> contain >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
839838
839+ /**拼接条件
840+ * @param not
841+ * @param condition
842+ * @return
843+ */
844+ private static String getCondition (boolean not , String condition ) {
845+ return not ? NOT + "(" + condition + ")" : condition ;
846+ }
847+
840848
841849 /**转为JSONArray
842850 * @param tv
0 commit comments