Skip to content

Commit d013830

Browse files
committed
格式化代码
1 parent 3d6dd88 commit d013830

File tree

4 files changed

+606
-606
lines changed

4 files changed

+606
-606
lines changed

APIJSONORM/src/main/java/apijson/orm/AbstractObjectParser.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,10 @@ public AbstractObjectParser(@NotNull JSONObject request, String parentPath, SQLC
8787

8888
this.type = arrayConfig == null ? 0 : arrayConfig.getType();
8989
this.joinList = arrayConfig == null ? null : arrayConfig.getJoinList();
90-
90+
9191
this.isTable = isTable; // apijson.JSONObject.isTableKey(table);
9292
this.isArrayMainTable = isArrayMainTable; // isSubquery == false && this.isTable && this.type == SQLConfig.TYPE_ITEM_CHILD_0 && RequestMethod.isGetMethod(method, true);
93-
// this.isReuse = isReuse; // isArrayMainTable && arrayConfig != null && arrayConfig.getPosition() > 0;
93+
// this.isReuse = isReuse; // isArrayMainTable && arrayConfig != null && arrayConfig.getPosition() > 0;
9494

9595
this.objectCount = 0;
9696
this.arrayCount = 0;
@@ -182,11 +182,11 @@ public AbstractObjectParser parse(String name, boolean isReuse) throws Exception
182182
apijson.orm.Entry<String, String> tentry = Pair.parseEntry(name, true);
183183
this.table = tentry.getKey();
184184
this.alias = tentry.getValue();
185-
185+
186186
Log.d(TAG, "AbstractObjectParser parentPath = " + parentPath + "; name = " + name + "; table = " + table + "; alias = " + alias);
187187
Log.d(TAG, "AbstractObjectParser type = " + type + "; isTable = " + isTable + "; isArrayMainTable = " + isArrayMainTable);
188188
Log.d(TAG, "AbstractObjectParser isEmpty = " + request.isEmpty() + "; tri = " + tri + "; drop = " + drop);
189-
189+
190190
breakParse = false;
191191

192192
response = new JSONObject(true);//must init
@@ -224,8 +224,8 @@ public AbstractObjectParser parse(String name, boolean isReuse) throws Exception
224224
whereList = new ArrayList<String>(Arrays.asList(combine != null ? combine : new String[]{}));
225225
whereList.add(apijson.JSONRequest.KEY_ID);
226226
whereList.add(apijson.JSONRequest.KEY_ID_IN);
227-
// whereList.add(apijson.JSONRequest.KEY_USER_ID);
228-
// whereList.add(apijson.JSONRequest.KEY_USER_ID_IN);
227+
// whereList.add(apijson.JSONRequest.KEY_USER_ID);
228+
// whereList.add(apijson.JSONRequest.KEY_USER_ID_IN);
229229
}
230230
//条件>>>>>>>>>>>>>>>>>>>
231231

@@ -292,7 +292,7 @@ else if (method == PUT && value instanceof JSONArray && (whereList == null || wh
292292
if (parser.getGlobleDatasource() != null && sqlRequest.get(JSONRequest.KEY_DATASOURCE) == null) {
293293
sqlRequest.put(JSONRequest.KEY_DATASOURCE, parser.getGlobleDatasource());
294294
}
295-
295+
296296
if (isSubquery == false) { //解决 SQL 语法报错,子查询不能 EXPLAIN
297297
if (parser.getGlobleExplain() != null && sqlRequest.get(JSONRequest.KEY_EXPLAIN) == null) {
298298
sqlRequest.put(JSONRequest.KEY_EXPLAIN, parser.getGlobleExplain());
@@ -818,10 +818,10 @@ public void onChildResponse() throws Exception {
818818
if (child == null
819819
|| (child instanceof JSONObject && ((JSONObject) child).isEmpty())
820820
|| (child instanceof JSONArray && ((JSONArray) child).isEmpty())
821-
) {
821+
) {
822822
continue;
823823
}
824-
824+
825825
response.put(entry.getKey(), child );
826826
index ++;
827827
}

APIJSONORM/src/main/java/apijson/orm/AbstractParser.java

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ public AbstractParser<T> setGlobleDatasource(String globleDatasource) {
209209
this.globleDatasource = globleDatasource;
210210
return this;
211211
}
212-
212+
213213
protected Boolean globleExplain;
214214
public AbstractParser<T> setGlobleExplain(Boolean globleExplain) {
215215
this.globleExplain = globleExplain;
@@ -516,7 +516,7 @@ public JSONObject parseCorrectRequest(RequestMethod method, String tag, int vers
516516

517517
//获取指定的JSON结构 >>>>>>>>>>>>>>
518518
JSONObject target = wrapRequest(method, tag, object, true);
519-
519+
520520
//JSONObject clone 浅拷贝没用,Structure.parse 会导致 structure 里面被清空,第二次从缓存里取到的就是 {}
521521
return getVerifier().verifyRequest(method, name, target, request, maxUpdateCount, getGlobleDatabase(), getGlobleSchema(), creator);
522522
}
@@ -529,7 +529,7 @@ public JSONObject parseCorrectRequest(RequestMethod method, String tag, int vers
529529
*/
530530
public static JSONObject wrapRequest(RequestMethod method, String tag, JSONObject object, boolean isStructure) {
531531
boolean putTag = ! isStructure;
532-
532+
533533
if (object == null || object.containsKey(tag)) { //tag 是 Table 名或 Table[]
534534
if (putTag) {
535535
if (object == null) {
@@ -549,18 +549,18 @@ public static JSONObject wrapRequest(RequestMethod method, String tag, JSONObjec
549549
if (isDiffArrayKey) { //自动为 tag = Comment:[] 的 { ... } 新增键值对为 { "Comment[]":[], "TYPE": { "Comment[]": "OBJECT[]" } ... }
550550
if (isStructure && (method == RequestMethod.POST || method == RequestMethod.PUT)) {
551551
String arrKey = key + "[]";
552-
552+
553553
if (target.containsKey(arrKey) == false) {
554554
target.put(arrKey, new JSONArray());
555555
}
556-
556+
557557
try {
558558
JSONObject type = target.getJSONObject(Operation.TYPE.name());
559559
if (type == null || (type.containsKey(arrKey) == false)) {
560560
if (type == null) {
561561
type = new JSONObject(true);
562562
}
563-
563+
564564
type.put(arrKey, "OBJECT[]");
565565
target.put(Operation.TYPE.name(), type);
566566
}
@@ -581,15 +581,15 @@ else if (target.containsKey(key) == false) {
581581
}
582582
}
583583
}
584-
584+
585585
if (putTag) {
586586
target.put(JSONRequest.KEY_TAG, tag);
587587
}
588-
588+
589589
return target;
590590
}
591591

592-
592+
593593
/**新建带状态内容的JSONObject
594594
* @param code
595595
* @param msg
@@ -835,7 +835,7 @@ public JSONObject getStructure(@NotNull String table, String method, String tag,
835835

836836

837837
protected Map<String, ObjectParser> arrayObjectParserCacheMap = new HashMap<>();
838-
838+
839839
// protected SQLConfig itemConfig;
840840
/**获取单个对象,该对象处于parentObject内
841841
* @param parentPath parentObject的路径
@@ -871,7 +871,7 @@ public JSONObject onObjectParse(final JSONObject request
871871
}
872872
}
873873
}
874-
874+
875875
apijson.orm.Entry<String, String> entry = Pair.parseEntry(name, true);
876876
String table = entry.getKey(); //Comment
877877
// String alias = entry.getValue(); //to
@@ -884,15 +884,15 @@ public JSONObject onObjectParse(final JSONObject request
884884
if (isReuse) { // 数组主表使用专门的缓存数据
885885
op = arrayObjectParserCacheMap.get(parentPath.substring(0, parentPath.lastIndexOf("[]") + 2));
886886
}
887-
887+
888888
if (op == null) {
889889
op = createObjectParser(request, parentPath, arrayConfig, isSubquery, isTable, isArrayMainTable);
890890
}
891891
op = op.parse(name, isReuse);
892-
892+
893893
JSONObject response = null;
894894
if (op != null) {//SQL查询结果为空时,functionMap和customMap没有意义
895-
895+
896896
if (arrayConfig == null) { //Common
897897
response = op.setSQLConfig().executeSQL().response();
898898
}
@@ -901,11 +901,11 @@ public JSONObject onObjectParse(final JSONObject request
901901

902902
//total 这里不能用arrayConfig.getType(),因为在createObjectParser.onChildParse传到onObjectParse时已被改掉
903903
if (type == SQLConfig.TYPE_ITEM_CHILD_0 && query != JSONRequest.QUERY_TABLE && position == 0) {
904-
904+
905905
RequestMethod method = op.getMethod();
906906
JSONObject rp = op.setMethod(RequestMethod.HEAD).setSQLConfig().executeSQL().getSqlReponse();
907907
op.setMethod(method);
908-
908+
909909
if (rp != null) {
910910
int index = parentPath.lastIndexOf("]/");
911911
if (index >= 0) {
@@ -934,7 +934,7 @@ public JSONObject onObjectParse(final JSONObject request
934934
pagination.put(JSONResponse.KEY_MORE, page < max);
935935
pagination.put(JSONResponse.KEY_FIRST, page == 0);
936936
pagination.put(JSONResponse.KEY_LAST, page == max);
937-
937+
938938
putQueryResult(pathPrefix + JSONResponse.KEY_INFO, pagination);
939939

940940
if (total <= count*page) {
@@ -963,9 +963,9 @@ public JSONObject onObjectParse(final JSONObject request
963963
arrayObjectParserCacheMap.put(parentPath.substring(0, parentPath.lastIndexOf("[]") + 2), op);
964964
}
965965
}
966-
// else {
967-
// op.recycle();
968-
// }
966+
// else {
967+
// op.recycle();
968+
// }
969969
op = null;
970970
}
971971

@@ -1196,13 +1196,13 @@ else if (join != null){
11961196
throw new IllegalArgumentException(JSONRequest.KEY_JOIN + ":value 中 value 的 Table 值 " + table + " 不合法!"
11971197
+ "必须为 &/Table0/key0,</Table1:alias1/key1,... 这种形式!且 Table0 必须满足大写字母开头的表对象英文单词 key 格式!");
11981198
}
1199-
1199+
12001200
String alias = entry.getValue(); //owner
12011201
if (StringUtil.isNotEmpty(alias, true) && StringUtil.isName(alias) == false) {
12021202
throw new IllegalArgumentException(JSONRequest.KEY_JOIN + ":value 中 value 的 alias 值 " + alias + " 不合法!"
12031203
+ "必须为 &/Table0/key0,</Table1:alias1/key1,... 这种形式!且 Table:alias 的 alias 必须满足英文单词变量名格式!");
12041204
}
1205-
1205+
12061206
String key = StringUtil.isEmpty(table, true) ? null : path.substring(index + 1);//id@
12071207

12081208
//取出Table对应的JSONObject,及内部引用赋值 key:value
@@ -1212,7 +1212,7 @@ else if (join != null){
12121212
catch (Exception e2) {
12131213
throw new IllegalArgumentException(JSONRequest.KEY_JOIN + ":'" + path + "' 对应的 " + tableKey + ":value 中 value 类型不合法!必须是 {} 这种 JSONObject 格式!" + e2.getMessage());
12141214
}
1215-
1215+
12161216
targetPath = tableObj == null ? null : tableObj.getString(key);
12171217
if (StringUtil.isEmpty(targetPath, true)) {
12181218
throw new IllegalArgumentException("/" + path + ":value 中 value 值 " + targetPath + " 不合法!必须为引用赋值的路径 '/targetTable/targetKey' !");
@@ -1240,37 +1240,37 @@ else if (join != null){
12401240
// if (StringUtil.isNotEmpty(targetAlias, true) && StringUtil.isName(targetAlias) == false) {
12411241
// throw new IllegalArgumentException("/" + path + ":'/targetTable:targetAlias/targetKey' 中 targetAlias 值 " + targetAlias + " 不合法!必须满足英文单词变量名格式!");
12421242
// }
1243-
1243+
12441244
targetTable = targetTableKey; // 主表不允许别名
12451245
if (StringUtil.isName(targetTable) == false) {
12461246
throw new IllegalArgumentException("/" + path + ":'/targetTable/targetKey' 中 targetTable 值 " + targetTable + " 不合法!必须满足大写字母开头的表对象英文单词 key 格式!");
12471247
}
1248-
1248+
12491249
//对引用的JSONObject添加条件
12501250
try {
12511251
targetObj = request.getJSONObject(targetTableKey);
12521252
}
12531253
catch (Exception e2) {
12541254
throw new IllegalArgumentException("/" + path + ":'/targetTable/targetKey' 中路径对应的 '" + targetTableKey + "':value 中 value 类型不合法!必须是 {} 这种 JSONObject 格式!" + e2.getMessage());
12551255
}
1256-
1256+
12571257
if (targetObj == null) {
12581258
throw new IllegalArgumentException("/" + path + ":'/targetTable/targetKey' 中路径对应的对象 '" + targetTableKey + "':{} 不存在或值为 null !必须是 {} 这种 JSONObject 格式!");
12591259
}
12601260

12611261
// 保证和 SQLExcecutor 缓存的 Config 里 where 顺序一致,生成的 SQL 也就一致 <<<<<<<<<
12621262
// AbstractSQLConfig.newSQLConfig 中强制把 id, id{}, userId, userId{} 放到了最前面 tableObj.put(key, tableObj.remove(key));
1263-
1263+
12641264
if (tableObj.size() > 1) { // 把 key 强制放最前,AbstractSQLExcecutor 中 config.putWhere 也是放尽可能最前
12651265
JSONObject newTableObj = new JSONObject(tableObj.size(), true);
12661266
newTableObj.put(key, tableObj.remove(key));
12671267
newTableObj.putAll(tableObj);
1268-
1268+
12691269
tableObj = newTableObj;
12701270
request.put(tableKey, tableObj);
12711271
}
12721272
// 保证和 SQLExcecutor 缓存的 Config 里 where 顺序一致,生成的 SQL 也就一致 >>>>>>>>>
1273-
1273+
12741274

12751275
Join j = new Join();
12761276
j.setPath(path);
@@ -1285,7 +1285,7 @@ else if (join != null){
12851285
j.setKeyAndType(key);
12861286
j.setRequest(getJoinObject(table, tableObj, key));
12871287
j.setOuter((JSONObject) e.getValue());
1288-
1288+
12891289
if (StringUtil.isName(j.getKey()) == false) {
12901290
throw new IllegalArgumentException(JSONRequest.KEY_JOIN + ":value 中 value 的 key@ 中 key 值 " + j.getKey() + " 不合法!必须满足英文单词变量名格式!");
12911291
}
@@ -1601,7 +1601,7 @@ public static JSONObject getJSONObject(JSONObject object, String key) {
16011601
public static final String KEY_CONFIG = "config";
16021602

16031603
public static final String KEY_SQL = "sql";
1604-
1604+
16051605
protected Map<String, List<JSONObject>> arrayMainCacheMap = new HashMap<>();
16061606
public void putArrayMainCache(String arrayPath, List<JSONObject> mainTableDataList) {
16071607
arrayMainCacheMap.put(arrayPath, mainTableDataList);
@@ -1613,8 +1613,8 @@ public JSONObject getArrayMainCacheItem(String arrayPath, int position) {
16131613
List<JSONObject> list = getArrayMainCache(arrayPath);
16141614
return list == null || position >= list.size() ? null : list.get(position);
16151615
}
1616-
1617-
1616+
1617+
16181618

16191619
/**执行 SQL 并返回 JSONObject
16201620
* @param config
@@ -1636,7 +1636,7 @@ public JSONObject executeSQL(SQLConfig config, boolean isSubquery) throws Except
16361636

16371637
try {
16381638
JSONObject result;
1639-
1639+
16401640
boolean explain = config.isExplain();
16411641
if (explain) {
16421642
//如果先执行 explain,则 execute 会死循环,所以只能先执行非 explain

0 commit comments

Comments
 (0)