Skip to content

Commit 18ac4c2

Browse files
committed
Java:新增支持 /reload 加参数 "value": { "id": 30 } 传过滤条件来增量热重载配置,解决腾讯 CSIG 某项目 3300 多张表 /reload 一次加载全部 Access 表几千条数据要几分钟;升级 APIJSON 和 apijson-framework 版本分别至 4.4.8 和 4.5.0
1 parent 68d3c43 commit 18ac4c2

File tree

5 files changed

+16
-10
lines changed

5 files changed

+16
-10
lines changed

APIJSON-Java-Server/APIJSONBoot/pom.xml

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
<groupId>apijson.boot</groupId>
77
<artifactId>apijson-boot</artifactId>
8-
<version>4.4.9</version>
8+
<version>4.5.0</version>
99
<packaging>jar</packaging>
1010

1111
<name>APIJSONBoot</name>
@@ -41,12 +41,12 @@
4141
<dependency>
4242
<groupId>com.github.Tencent</groupId>
4343
<artifactId>APIJSON</artifactId>
44-
<version>4.4.7</version>
44+
<version>4.4.8</version>
4545
</dependency>
4646
<dependency>
4747
<groupId>com.github.APIJSON</groupId>
4848
<artifactId>apijson-framework</artifactId>
49-
<version>4.4.9</version>
49+
<version>4.5.0</version>
5050
</dependency>
5151
<!-- 可使用 libs 目录的 apijson-orm.jar 和 apijson-framework.jar 来替代,两种方式二选一 >>>>>>>>>> -->
5252

APIJSON-Java-Server/APIJSONBoot/src/main/java/apijson/boot/DemoController.java

+10-4
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,7 @@ public String openHead(@PathVariable String request, HttpSession session) {
257257
public static final String VERIFY = "verify";
258258

259259
public static final String TYPE = "type";
260+
public static final String VALUE = "value";
260261

261262

262263

@@ -268,7 +269,10 @@ public String openHead(@PathVariable String request, HttpSession session) {
268269
{
269270
"type": "ALL", //重载对象,ALL, FUNCTION, REQUEST, ACCESS,非必须
270271
"phone": "13000082001",
271-
"verify": "1234567" //验证码,对应类型为 Verify.TYPE_RELOAD
272+
"verify": "1234567", //验证码,对应类型为 Verify.TYPE_RELOAD
273+
"value": { // 自定义增量更新条件
274+
"id": 1 // 过滤条件,符合 APIJSON 查询功能符即可
275+
}
272276
}
273277
* </pre>
274278
*/
@@ -277,11 +281,13 @@ public String openHead(@PathVariable String request, HttpSession session) {
277281
public JSONObject reload(@RequestBody String request) {
278282
JSONObject requestObject = null;
279283
String type;
284+
JSONObject value;
280285
String phone;
281286
String verify;
282287
try {
283288
requestObject = DemoParser.parseRequest(request);
284289
type = requestObject.getString(TYPE);
290+
value = requestObject.getJSONObject(VALUE);
285291
phone = requestObject.getString(PHONE);
286292
verify = requestObject.getString(VERIFY);
287293
} catch (Exception e) {
@@ -300,7 +306,7 @@ public JSONObject reload(@RequestBody String request) {
300306

301307
if (reloadAll || "ACCESS".equals(type)) {
302308
try {
303-
result.put(ACCESS_, DemoVerifier.initAccess());
309+
result.put(ACCESS_, DemoVerifier.initAccess(false, null, value));
304310
} catch (ServerException e) {
305311
e.printStackTrace();
306312
result.put(ACCESS_, DemoParser.newErrorResult(e));
@@ -309,7 +315,7 @@ public JSONObject reload(@RequestBody String request) {
309315

310316
if (reloadAll || "FUNCTION".equals(type)) {
311317
try {
312-
result.put(FUNCTION_, DemoFunctionParser.init());
318+
result.put(FUNCTION_, DemoFunctionParser.init(false, null, value));
313319
} catch (ServerException e) {
314320
e.printStackTrace();
315321
result.put(FUNCTION_, DemoParser.newErrorResult(e));
@@ -318,7 +324,7 @@ public JSONObject reload(@RequestBody String request) {
318324

319325
if (reloadAll || "REQUEST".equals(type)) {
320326
try {
321-
result.put(REQUEST_, DemoVerifier.initRequest());
327+
result.put(REQUEST_, DemoVerifier.initRequest(false, null, value));
322328
} catch (ServerException e) {
323329
e.printStackTrace();
324330
result.put(REQUEST_, DemoParser.newErrorResult(e));

APIJSON-Java-Server/APIJSONFinal/pom.xml

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<groupId>apijson.jfinal</groupId>
55
<artifactId>apijson-final</artifactId>
66
<packaging>jar</packaging>
7-
<version>4.4.9</version>
7+
<version>4.5.0</version>
88
<name>Demo project for APIJSON Server based on JFinal</name>
99
<url>http://maven.apache.org</url>
1010
<dependencies>
@@ -24,12 +24,12 @@
2424
<dependency>
2525
<groupId>com.github.Tencent</groupId>
2626
<artifactId>APIJSON</artifactId>
27-
<version>4.4.7</version>
27+
<version>4.4.8</version>
2828
</dependency>
2929
<dependency>
3030
<groupId>com.github.APIJSON</groupId>
3131
<artifactId>apijson-framework</artifactId>
32-
<version>4.4.9</version>
32+
<version>4.5.0</version>
3333
</dependency>
3434
<!-- 可使用 libs 目录的 apijson-orm.jar 和 apijson-framework.jar 来替代,两种方式二选一 >>>>>>>>>> -->
3535

0 commit comments

Comments
 (0)