Skip to content

Commit 5977535

Browse files
committed
Server:新增自动化版本管理
1 parent fe2713e commit 5977535

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

APIJSON-Java-Server/APIJSON-Eclipse/src/main/java/zuo/biao/apijson/JSONRequest.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ public JSONRequest(String name, Object object) {
5151

5252

5353
public static final String KEY_TAG = "tag";//只在最外层,最外层用JSONRequest
54+
public static final String KEY_VERSION = "version";//只在最外层,最外层用JSONRequest
5455

5556
/**set "tag":tag in outermost layer
5657
* for write operations
@@ -60,6 +61,14 @@ public JSONRequest(String name, Object object) {
6061
public JSONRequest setTag(String tag) {
6162
return puts(KEY_TAG, tag);
6263
}
64+
/**set "version":version in outermost layer
65+
* for target version of request
66+
* @param version
67+
* @return
68+
*/
69+
public JSONRequest setVersion(String version) {
70+
return puts(KEY_VERSION, version);
71+
}
6372

6473

6574
//array object <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

APIJSON-Java-Server/APIJSON-Eclipse/src/main/java/zuo/biao/apijson/server/Parser.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -374,11 +374,12 @@ public static JSONObject getCorrectRequest(@NotNull RequestMethod method, JSONOb
374374
if (StringUtil.isNotEmpty(tag, true) == false) {
375375
throw new IllegalArgumentException("请设置tag!一般是Table名");
376376
}
377+
int version = request.getIntValue(JSONRequest.KEY_VERSION);
377378

378379
JSONObject object = null;
379380
String error = "";
380381
try {
381-
object = getStructure(method, "Request", JSONRequest.KEY_TAG, tag);
382+
object = getStructure(method, "Request", JSONRequest.KEY_TAG, tag, version);
382383
} catch (Exception e) {
383384
error = e.getMessage();
384385
}
@@ -396,6 +397,7 @@ public static JSONObject getCorrectRequest(@NotNull RequestMethod method, JSONOb
396397
//获取指定的JSON结构 >>>>>>>>>>>>>>
397398

398399
request.remove(JSONRequest.KEY_TAG);
400+
request.remove(JSONRequest.KEY_VERSION);
399401
return Structure.parseRequest(method, "", (JSONObject) target.clone(), request);
400402
}
401403

@@ -431,11 +433,12 @@ public static JSONObject getCorrectResponse(@NotNull final RequestMethod method
431433
* @param table
432434
* @param key
433435
* @param value
436+
* @param version
434437
* @return
435438
* @throws Exception
436439
*/
437440
public static JSONObject getStructure(@NotNull final RequestMethod method, @NotNull String table,
438-
String key, String value) throws Exception {
441+
String key, String value, int version) throws Exception {
439442
//获取指定的JSON结构 <<<<<<<<<<<<<<
440443
SQLConfig config = new SQLConfig(GET, table);
441444
config.setColumn("structure");
@@ -445,7 +448,12 @@ public static JSONObject getStructure(@NotNull final RequestMethod method, @NotN
445448
if (key != null) {
446449
where.put(key, value);
447450
}
451+
if (version > 0) {
452+
where.put(JSONRequest.KEY_VERSION + "{}", ">=" + version);
453+
}
448454
config.setWhere(where);
455+
config.setOrder(JSONRequest.KEY_VERSION + (version > 0 ? "+" : "-"));
456+
config.setCount(1);
449457

450458
SQLExecutor qh = new SQLExecutor();
451459

0 commit comments

Comments
 (0)