Skip to content

Commit

Permalink
Java:新增支持 /reload 加参数 "value": { "id": 30 } 传过滤条件来增量热重载配置,解决腾讯 CSIG 某…
Browse files Browse the repository at this point in the history
…项目 3300 多张表 /reload 一次加载全部 Access 表几千条数据要几分钟;升级 APIJSON 和 apijson-framework 版本分别至 4.4.8 和 4.5.0
  • Loading branch information
TommyLemon committed Dec 28, 2020
1 parent 68d3c43 commit 18ac4c2
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 10 deletions.
Binary file not shown.
6 changes: 3 additions & 3 deletions APIJSON-Java-Server/APIJSONBoot/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>apijson.boot</groupId>
<artifactId>apijson-boot</artifactId>
<version>4.4.9</version>
<version>4.5.0</version>
<packaging>jar</packaging>

<name>APIJSONBoot</name>
Expand Down Expand Up @@ -41,12 +41,12 @@
<dependency>
<groupId>com.github.Tencent</groupId>
<artifactId>APIJSON</artifactId>
<version>4.4.7</version>
<version>4.4.8</version>
</dependency>
<dependency>
<groupId>com.github.APIJSON</groupId>
<artifactId>apijson-framework</artifactId>
<version>4.4.9</version>
<version>4.5.0</version>
</dependency>
<!-- 可使用 libs 目录的 apijson-orm.jar 和 apijson-framework.jar 来替代,两种方式二选一 >>>>>>>>>> -->

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ public String openHead(@PathVariable String request, HttpSession session) {
public static final String VERIFY = "verify";

public static final String TYPE = "type";
public static final String VALUE = "value";



Expand All @@ -268,7 +269,10 @@ public String openHead(@PathVariable String request, HttpSession session) {
{
"type": "ALL", //重载对象,ALL, FUNCTION, REQUEST, ACCESS,非必须
"phone": "13000082001",
"verify": "1234567" //验证码,对应类型为 Verify.TYPE_RELOAD
"verify": "1234567", //验证码,对应类型为 Verify.TYPE_RELOAD
"value": { // 自定义增量更新条件
"id": 1 // 过滤条件,符合 APIJSON 查询功能符即可
}
}
* </pre>
*/
Expand All @@ -277,11 +281,13 @@ public String openHead(@PathVariable String request, HttpSession session) {
public JSONObject reload(@RequestBody String request) {
JSONObject requestObject = null;
String type;
JSONObject value;
String phone;
String verify;
try {
requestObject = DemoParser.parseRequest(request);
type = requestObject.getString(TYPE);
value = requestObject.getJSONObject(VALUE);
phone = requestObject.getString(PHONE);
verify = requestObject.getString(VERIFY);
} catch (Exception e) {
Expand All @@ -300,7 +306,7 @@ public JSONObject reload(@RequestBody String request) {

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

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

if (reloadAll || "REQUEST".equals(type)) {
try {
result.put(REQUEST_, DemoVerifier.initRequest());
result.put(REQUEST_, DemoVerifier.initRequest(false, null, value));
} catch (ServerException e) {
e.printStackTrace();
result.put(REQUEST_, DemoParser.newErrorResult(e));
Expand Down
Binary file not shown.
6 changes: 3 additions & 3 deletions APIJSON-Java-Server/APIJSONFinal/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<groupId>apijson.jfinal</groupId>
<artifactId>apijson-final</artifactId>
<packaging>jar</packaging>
<version>4.4.9</version>
<version>4.5.0</version>
<name>Demo project for APIJSON Server based on JFinal</name>
<url>http://maven.apache.org</url>
<dependencies>
Expand All @@ -24,12 +24,12 @@
<dependency>
<groupId>com.github.Tencent</groupId>
<artifactId>APIJSON</artifactId>
<version>4.4.7</version>
<version>4.4.8</version>
</dependency>
<dependency>
<groupId>com.github.APIJSON</groupId>
<artifactId>apijson-framework</artifactId>
<version>4.4.9</version>
<version>4.5.0</version>
</dependency>
<!-- 可使用 libs 目录的 apijson-orm.jar 和 apijson-framework.jar 来替代,两种方式二选一 >>>>>>>>>> -->

Expand Down

0 comments on commit 18ac4c2

Please sign in to comment.