Skip to content

Commit 278ff6d

Browse files
committed
原始 SQL 片段 @raw:"key" 新增支持条件范围 key{}: "(Comment.userId=to.userId)"、比较运算 key>: "to.momentId"、过滤字段 @column: "SUBSTRING_INDEX(SUBSTRING_INDEX(content,',',1),',',-1)"
1 parent b4667b3 commit 278ff6d

File tree

4 files changed

+224
-78
lines changed

4 files changed

+224
-78
lines changed

APIJSONORM/src/main/java/apijson/JSONObject.java

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,8 @@ public JSONObject setUserIdIn(List<Object> list) {
145145
public static final String KEY_GROUP = "@group"; //分组方式
146146
public static final String KEY_HAVING = "@having"; //聚合函数条件,一般和@group一起用
147147
public static final String KEY_ORDER = "@order"; //排序方式
148+
public static final String KEY_RAW = "@raw"; // 自定义原始 SQL 片段
148149
public static final String KEY_JSON = "@json"; //SQL Server 把字段转为 JSON 输出
149-
public static final String KEY_RAW = "@raw"; //自定义where条件拼接
150150

151151
public static final List<String> TABLE_KEY_LIST;
152152
static {
@@ -162,8 +162,8 @@ public JSONObject setUserIdIn(List<Object> list) {
162162
TABLE_KEY_LIST.add(KEY_GROUP);
163163
TABLE_KEY_LIST.add(KEY_HAVING);
164164
TABLE_KEY_LIST.add(KEY_ORDER);
165-
TABLE_KEY_LIST.add(KEY_JSON);
166165
TABLE_KEY_LIST.add(KEY_RAW);
166+
TABLE_KEY_LIST.add(KEY_JSON);
167167
}
168168

169169
//@key关键字都放这个类 >>>>>>>>>>>>>>>>>>>>>>
@@ -325,10 +325,29 @@ public JSONObject setOrder(String keys) {
325325
return puts(KEY_ORDER, keys);
326326
}
327327

328+
/**set keys to raw
329+
* @param keys "key0,key1,key2..."
330+
* @return
331+
*/
332+
public JSONObject setRaw(String keys) {
333+
return puts(KEY_RAW, keys);
334+
}
335+
328336
/**set keys to cast to json
329337
* @param keys "key0,key1,key2..."
330338
* @return
331339
*/
340+
public JSONObject setJson(String keys) {
341+
return puts(KEY_JSON, keys);
342+
}
343+
344+
/**用 setJson 替代。
345+
* set keys to cast to json
346+
* @param keys "key0,key1,key2..."
347+
* @return
348+
* @see #{@link #setJson(String)}
349+
*/
350+
@Deprecated
332351
public JSONObject setJSON(String keys) {
333352
return puts(KEY_JSON, keys);
334353
}

APIJSONORM/src/main/java/apijson/StringUtil.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -736,6 +736,14 @@ public static String[] split(String s) {
736736
public static String[] split(String s, String split) {
737737
return split(s, split, true);
738738
}
739+
/**将s用split分割成String[]
740+
* @param s
741+
* @param trim 去掉前后两端的split
742+
* @return
743+
*/
744+
public static String[] split(String s, boolean trim) {
745+
return split(s, null, trim);
746+
}
739747
/**将s用split分割成String[]
740748
* @param s
741749
* @param split
@@ -747,7 +755,7 @@ public static String[] split(String s, String split, boolean trim) {
747755
if (s.isEmpty()) {
748756
return null;
749757
}
750-
if (isNotEmpty(split, false) == false) {
758+
if (isEmpty(split, false)) {
751759
split = ",";
752760
}
753761
if (trim) {

0 commit comments

Comments
 (0)