Skip to content

Commit 47ebfef

Browse files
committed
从主项目同步过来
1 parent 17de0bc commit 47ebfef

32 files changed

+1402
-1307
lines changed

src/main/java/apijson/JSONObject.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
import java.util.List;
1919
import java.util.Map;
2020

21+
import apijson.server.JSONRequest;
22+
2123
/**use this class instead of com.alibaba.fastjson.JSONObject
2224
* @author Lemon
2325
* @see #put
@@ -78,6 +80,13 @@ public static boolean isArrayKey(String key) {
7880
public static boolean isTableKey(String key) {
7981
return StringUtil.isBigName(key);
8082
}
83+
/**判断是否为对应Table数组的 key
84+
* @param key
85+
* @return
86+
*/
87+
public static boolean isTableArray(String key) {
88+
return isArrayKey(key) && isTableKey(key.substring(0, key.length() - KEY_ARRAY.length()));
89+
}
8190
//judge >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
8291

8392

@@ -332,7 +341,7 @@ public JSONObject setOrder(String keys) {
332341
public JSONObject setJSON(String keys) {
333342
return puts(KEY_JSON, keys);
334343
}
335-
344+
336345

337346
//JSONObject内关键词 key >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
338347

@@ -433,7 +442,7 @@ public JSONObject puts(Object value) {
433442
}
434443
/**put and return this
435444
* @param key
436-
* @param value
445+
* @param value
437446
* @return this
438447
* @see {@link #put(String, Object)}
439448
*/

src/main/java/apijson/JSONRequest.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,14 +87,14 @@ public JSONRequest setFormat(Boolean format) {
8787
public static final int QUERY_TABLE = 0;
8888
public static final int QUERY_TOTAL = 1;
8989
public static final int QUERY_ALL = 2;
90-
90+
9191
public static final String QUERY_TABLE_STRING = "TABLE";
9292
public static final String QUERY_TOTAL_STRING = "TOTAL";
9393
public static final String QUERY_ALL_STRING = "ALL";
9494

9595
public static final String SUBQUERY_RANGE_ALL = "ALL";
9696
public static final String SUBQUERY_RANGE_ANY = "ANY";
97-
97+
9898
public static final String KEY_QUERY = "query";
9999
public static final String KEY_COUNT = "count";
100100
public static final String KEY_PAGE = "page";
@@ -137,15 +137,15 @@ public JSONRequest setCount(int count) {
137137
public JSONRequest setPage(int page) {
138138
return puts(KEY_PAGE, page);
139139
}
140-
140+
141141
/**set joins of Main Table and it's Vice Tables in Array layer
142142
* @param joins "@/User/id@", "&/User/id@,>/Comment/momentId@" ...
143143
* @return
144144
*/
145145
public JSONRequest setJoin(String... joins) {
146146
return puts(KEY_JOIN, StringUtil.getString(joins));
147147
}
148-
148+
149149
/**set range for Subquery
150150
* @param range
151151
* @return
@@ -155,15 +155,15 @@ public JSONRequest setJoin(String... joins) {
155155
public JSONRequest setSubqueryRange(String range) {
156156
return puts(KEY_SUBQUERY_RANGE, range);
157157
}
158-
158+
159159
/**set from for Subquery
160160
* @param range
161161
* @return
162162
*/
163163
public JSONRequest setSubqueryFrom(String from) {
164164
return puts(KEY_SUBQUERY_FROM, from);
165165
}
166-
166+
167167
//array object >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
168168

169169

src/main/java/apijson/Log.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
public class Log {
2121

2222
public static boolean DEBUG = true;
23-
23+
2424
/**
2525
* @param TAG
2626
* @param msg

src/main/java/apijson/RequestMethod.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,38 +23,38 @@ public enum RequestMethod {
2323
* 常规获取数据方式
2424
*/
2525
GET,
26-
26+
2727
/**
2828
* 检查,默认是非空检查,返回数据总数
2929
*/
3030
HEAD,
31-
31+
3232
/**Safe, Single, Simple
3333
* <br > 限制性GET,通过POST来GET数据,不显示请求内容和返回结果,并且校验请求,一般用于对安全要求比较高的请求
3434
*/
3535
GETS,
36-
36+
3737
/**Safe, Single, Simple
3838
* <br > 限制性HEAD,通过POST来HEAD数据,不显示请求内容和返回结果,并且校验请求,一般用于对安全要求比较高的请求
3939
*/
4040
HEADS,
41-
41+
4242
/**
4343
* 新增(或者说插入)数据
4444
*/
4545
POST,
46-
46+
4747
/**
4848
* 修改数据,只修改传入字段对应的值
4949
*/
5050
PUT,
51-
51+
5252
/**
5353
* 删除数据
5454
*/
5555
DELETE;
56-
57-
56+
57+
5858
/**是否为GET请求方法
5959
* @param method
6060
* @param containPrivate 包含私密(非明文)获取方法GETS
@@ -64,7 +64,7 @@ public static boolean isGetMethod(RequestMethod method, boolean containPrivate)
6464
boolean is = method == null || method == GET;
6565
return containPrivate == false ? is : is || method == GETS;
6666
}
67-
67+
6868
/**是否为HEAD请求方法
6969
* @param method
7070
* @param containPrivate 包含私密(非明文)获取方法HEADS
@@ -74,15 +74,15 @@ public static boolean isHeadMethod(RequestMethod method, boolean containPrivate)
7474
boolean is = method == HEAD;
7575
return containPrivate == false ? is : is || method == HEADS;
7676
}
77-
77+
7878
/**是否为查询的请求方法
7979
* @param method
8080
* @return 读操作(GET型或HEAD型) - true, 写操作(POST,PUT,DELETE) - false
8181
*/
8282
public static boolean isQueryMethod(RequestMethod method) {
8383
return isGetMethod(method, true) || isHeadMethod(method, true);
8484
}
85-
85+
8686
/**是否为开放(不限制请求的结构或内容;明文,浏览器能直接访问及查看)的请求方法
8787
* @param method
8888
* @return
@@ -94,5 +94,5 @@ public static boolean isPublicMethod(RequestMethod method) {
9494
public static String getName(RequestMethod method) {
9595
return method == null ? GET.name() : method.name();
9696
}
97-
97+
9898
}

src/main/java/apijson/RequestRole.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public static RequestRole get(String name) throws Exception {
6060
return null;
6161
}
6262
try { //Enum.valueOf只要找不到对应的值就会抛异常
63-
return RequestRole.valueOf(StringUtil.toUpperCase(name));
63+
return RequestRole.valueOf(name);
6464
} catch (Exception e) {
6565
throw new IllegalArgumentException("角色 " + name + " 不存在!只能是[" + StringUtil.getString(NAMES) + "]中的一种!", e);
6666
}

src/main/java/apijson/SQL.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public class SQL {
2525
public static final String AS = " AS ";
2626
public static final String IS = " is ";
2727
public static final String NULL = " null ";
28-
28+
2929
//括号必须紧跟函数名! count (...) 报错!
3030
public static final String COUNT = "count";
3131
public static final String SUM = "sum";
@@ -34,7 +34,7 @@ public class SQL {
3434
public static final String AVG = "avg";
3535

3636
/**
37-
* isNull = true
37+
* isNull = true
3838
* @return {@link #isNull(boolean)}
3939
*/
4040
public static String isNull() {
@@ -195,7 +195,7 @@ public static String indexOf(String s, String c) {
195195
public static String replace(String s, String c1, String c2) {
196196
return "replace(" + s + ", " + c1 + ", " + c2 + ")";
197197
}
198-
198+
199199
/**
200200
* @param s1
201201
* @param s2
@@ -229,11 +229,11 @@ public static String toLowerCase(String s) {
229229
return "lower(" + s + ")";
230230
}
231231

232-
233-
232+
233+
234234

235235
//column and function<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
236-
236+
237237
/**字段
238238
* @param column
239239
* @return column.isEmpty() ? "*" : column;
@@ -249,7 +249,7 @@ public static String column(String column) {
249249
public static String columnAs(String column) {
250250
return count(column) + AS;
251251
}
252-
252+
253253
/**函数
254254
* @param column if (StringUtil.isEmpty(column, true) || column.contains(",")) -> column = null;
255255
* @return " " + fun + "(" + {@link #column(String)} + ") ";
@@ -267,7 +267,7 @@ public static String function(String fun, String column) {
267267
public static String functionAs(String fun, String column) {
268268
return function(fun, column) + AS + fun + " ";
269269
}
270-
270+
271271
/**计数
272272
* column = null
273273
* @return {@link #count(String)}
@@ -317,9 +317,9 @@ public static String avg(String column) {
317317
}
318318

319319
//column and function>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
320-
321-
322-
320+
321+
322+
323323
//search<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
324324

325325
public static final int SEARCH_TYPE_CONTAIN_FULL = 0;
@@ -392,7 +392,7 @@ public static String search(String s, int type, boolean ignoreCase) {
392392
return "%" + s + "%";
393393
}
394394
}
395-
395+
396396
//search>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
397397

398398
}

src/main/java/apijson/package-info.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@
1313
limitations under the License.*/
1414

1515
/**
16-
* the same files for server and client projects
16+
* the same files for server and client projects
1717
*/
1818
/**
1919
* @author Lemon
20-
*
20+
*
2121
*/
2222
package apijson;

0 commit comments

Comments
 (0)