1919import static zuo .biao .apijson .JSONObject .KEY_CONDITION ;
2020import static zuo .biao .apijson .JSONObject .KEY_GROUP ;
2121import static zuo .biao .apijson .JSONObject .KEY_HAVING ;
22+ import static zuo .biao .apijson .JSONObject .KEY_ID ;
23+ import static zuo .biao .apijson .JSONObject .KEY_ID_IN ;
2224import static zuo .biao .apijson .JSONObject .KEY_ORDER ;
2325import static zuo .biao .apijson .JSONObject .KEY_ROLE ;
2426import static zuo .biao .apijson .JSONObject .KEY_SCHEMA ;
2527import static zuo .biao .apijson .JSONRequest .KEY_COUNT ;
2628import static zuo .biao .apijson .JSONRequest .KEY_PAGE ;
2729import static zuo .biao .apijson .JSONRequest .KEY_QUERY ;
28- import static zuo .biao .apijson .JSONRequest .KEY_ID ;
29- import static zuo .biao .apijson .JSONRequest .KEY_ID_IN ;
3030import static zuo .biao .apijson .RequestMethod .DELETE ;
3131import static zuo .biao .apijson .RequestMethod .GET ;
3232import static zuo .biao .apijson .RequestMethod .POST ;
5454import apijson .demo .server .model .BaseModel ;
5555import apijson .demo .server .model .Privacy ;
5656import apijson .demo .server .model .User ;
57- import zuo .biao .apijson .JSONRequest ;
5857import zuo .biao .apijson .Log ;
5958import zuo .biao .apijson .RequestMethod ;
6059import zuo .biao .apijson .RequestRole ;
@@ -531,7 +530,7 @@ public static String getWhereString(RequestMethod method, Map<String, Object> wh
531530 continue ;
532531 }
533532
534- whereString += (isFirst ? "" : AND ) + condition ;
533+ whereString += (isFirst ? "" : AND ) + "(" + condition + ")" ;
535534
536535 isFirst = false ;
537536 }
@@ -639,7 +638,7 @@ public static String getSearchString(String key, Object[] values, int type) thro
639638 condition += (i <= 0 ? "" : (Logic .isAnd (type ) ? AND : OR )) + getLikeString (key , values [i ]);
640639 }
641640
642- return (Logic .isNot (type ) ? NOT : "" ) + "(" + condition + ")" ;
641+ return getCondition (Logic .isNot (type ), condition ) ;
643642 }
644643
645644 /**WHERE key LIKE 'value'
@@ -693,7 +692,7 @@ public static String getRegExpString(String key, Object[] values, int type) thro
693692 condition += (i <= 0 ? "" : (Logic .isAnd (type ) ? AND : OR )) + getRegExpString (key , (String ) values [i ]);
694693 }
695694
696- return (Logic .isNot (type ) ? NOT : "" ) + "(" + condition + ")" ;
695+ return getCondition (Logic .isNot (type ), condition ) ;
697696 }
698697
699698 /**WHERE key REGEXP 'value'
@@ -747,8 +746,7 @@ public static String getRangeString(String key, Object range) throws Exception {
747746 if (condition .isEmpty ()) {
748747 return "" ;
749748 }
750- condition = "(" + condition + ")" ;
751- return logic .isNot () ? NOT + condition : condition ;
749+ return getCondition (logic .isNot (), condition );
752750 }
753751
754752 throw new IllegalArgumentException (key + "{}:range 类型为" + range .getClass ().getSimpleName ()
@@ -770,7 +768,7 @@ public static String getInString(String key, Object[] in, boolean not) throws No
770768 throw new NotExistException (TAG + ".getInString(" + key + ", [], " + not
771769 + ") >> condition.isEmpty() >> IN()" );
772770 }
773- return (not ? NOT : "" ) + " IN " + " (" + condition + ")" ;
771+ return (not ? NOT : "" ) + " IN (" + condition + ")" ;
774772 }
775773 //{} range >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
776774
@@ -814,7 +812,7 @@ public static String getContainString(String key, Object[] childs, int type) thr
814812 childs [i ] = "\" " + childs [i ] + "\" " ;
815813 }
816814 condition += (i <= 0 ? "" : (Logic .isAnd (type ) ? AND : OR ))
817- + getSearchString (
815+ + "(" + getSearchString (
818816 key
819817 , new String []{
820818 "[" + childs [i ] + "]" , //全等
@@ -823,7 +821,7 @@ public static String getContainString(String key, Object[] childs, int type) thr
823821 "%, " + childs [i ] + "]" //末尾
824822 }
825823 , Logic .TYPE_OR
826- );
824+ ) + ")" ;
827825 }
828826 }
829827 if (condition .isEmpty ()) {
@@ -833,10 +831,19 @@ public static String getContainString(String key, Object[] childs, int type) thr
833831 if (condition .isEmpty ()) {
834832 return "" ;
835833 }
836- return (Logic .isNot (type ) ? NOT : "" ) + "(" + condition + ")" ;
834+ return getCondition (Logic .isNot (type ), condition ) ;
837835 }
838836 //<> contain >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
839837
838+ /**拼接条件
839+ * @param not
840+ * @param condition
841+ * @return
842+ */
843+ private static String getCondition (boolean not , String condition ) {
844+ return not ? NOT + "(" + condition + ")" : condition ;
845+ }
846+
840847
841848 /**转为JSONArray
842849 * @param tv
0 commit comments