Skip to content

Commit cd83258

Browse files
committed
Java:MultiDataSource 升级 APIJSON 5.3.0, apijson-framework 5.3.0, apijson-column1.2.7, apijson-router 1.0.6
1 parent e4682f7 commit cd83258

13 files changed

+56
-27
lines changed
Binary file not shown.
Binary file not shown.
Binary file not shown.

APIJSON-Java-Server/APIJSONBoot-MultiDataSource/pom.xml

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -67,35 +67,35 @@
6767
<dependency>
6868
<groupId>com.github.APIJSON</groupId>
6969
<artifactId>apijson-framework</artifactId>
70-
<version>5.2.0</version>
71-
<exclusions>
72-
<exclusion>
73-
<groupId>com.github.Tencent</groupId>
74-
<artifactId>APIJSON</artifactId>
75-
</exclusion>
76-
</exclusions>
70+
<version>5.3.0</version>
71+
<!-- <exclusions>-->
72+
<!-- <exclusion>-->
73+
<!-- <groupId>com.github.Tencent</groupId>-->
74+
<!-- <artifactId>APIJSON</artifactId>-->
75+
<!-- </exclusion>-->
76+
<!-- </exclusions>-->
7777
</dependency>
7878
<dependency>
7979
<groupId>com.github.APIJSON</groupId>
8080
<artifactId>apijson-column</artifactId>
81-
<version>1.2.5</version>
82-
<exclusions>
83-
<exclusion>
84-
<groupId>com.github.Tencent</groupId>
85-
<artifactId>APIJSON</artifactId>
86-
</exclusion>
87-
</exclusions>
81+
<version>1.2.7</version>
82+
<!-- <exclusions>-->
83+
<!-- <exclusion>-->
84+
<!-- <groupId>com.github.Tencent</groupId>-->
85+
<!-- <artifactId>APIJSON</artifactId>-->
86+
<!-- </exclusion>-->
87+
<!-- </exclusions>-->
8888
</dependency>
8989
<dependency>
9090
<groupId>com.github.APIJSON</groupId>
9191
<artifactId>apijson-router</artifactId>
92-
<version>1.0.6</version>
93-
<exclusions>
94-
<exclusion>
95-
<groupId>com.github.Tencent</groupId>
96-
<artifactId>APIJSON</artifactId>
97-
</exclusion>
98-
</exclusions>
92+
<version>1.0.8</version>
93+
<!-- <exclusions>-->
94+
<!-- <exclusion>-->
95+
<!-- <groupId>com.github.Tencent</groupId>-->
96+
<!-- <artifactId>APIJSON</artifactId>-->
97+
<!-- </exclusion>-->
98+
<!-- </exclusions>-->
9999
</dependency>
100100
<!-- 可使用 libs 目录的 apijson-orm.jar, apijson-framework.jar, apijson-column.jar 来替代,两种方式二选一 >>>>>>>>>> -->
101101

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

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2030,21 +2030,50 @@ public void invokeMethod(@RequestBody String request, HttpServletRequest servlet
20302030
super.invokeMethod(request, servletRequest);
20312031
}
20322032

2033+
// 为 UnitAuto 提供的单元测试接口 https://github.com/TommyLemon/UnitAuto >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
2034+
2035+
2036+
// 为 APIAuto, UnitAuto, SQLAuto 提供的后台 Headless 无 UI 测试转发接口 <<<<<<<<<<<<<<<<<<<<<<<<<<<
20332037

20342038
@GetMapping("/api/test/start")
2035-
public String startApiTest(HttpServletResponse response, HttpSession session) throws Exception {
2039+
public String startApiTest(HttpSession session) {
20362040
//response.sendRedirect("http://localhost:3000/test/start");
20372041
long id = 100000 + Math.round(899999*Math.random());
2038-
DemoParser.KEY_MAP.put(id, session); // 调这个接口一般是前端/CI/CD,调查询接口的是 Node,Session 不同 session.setAttribute("key", id);
2042+
DemoParser.KEY_MAP.put(String.valueOf(id), session); // 调这个接口一般是前端/CI/CD,调查询接口的是 Node,Session 不同 session.setAttribute("key", id);
20392043
return delegate("http://localhost:3000/test/start?key=" + id, null, null, null, null, HttpMethod.GET, session);
20402044
}
20412045
@GetMapping("/api/test/status")
2042-
public String getApiTestStatus(HttpServletResponse response, HttpSession session) throws Exception {
2046+
public String getApiTestStatus(@RequestParam(value = "key", required = false) String key, HttpSession session) {
20432047
//response.sendRedirect("http://localhost:3000/test/status");
2048+
DemoParser.KEY_MAP.remove(key);
20442049
return delegate("http://localhost:3000/test/status", null, null, null, null, HttpMethod.GET, session);
20452050
}
20462051

2047-
// 为 UnitAuto 提供的单元测试接口 https://github.com/TommyLemon/UnitAuto >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
2052+
@GetMapping("/unit/test/start")
2053+
public String startUnitTest(HttpSession session) {
2054+
long id = 100000 + Math.round(899999*Math.random());
2055+
DemoParser.KEY_MAP.put(String.valueOf(id), session); // 调这个接口一般是前端/CI/CD,调查询接口的是 Node,Session 不同 session.setAttribute("key", id);
2056+
return delegate("http://localhost:3001/test/start?key=" + id, null, null, null, null, HttpMethod.GET, session);
2057+
}
2058+
@GetMapping("/unit/test/status")
2059+
public String getUnitTestStatus(@RequestParam(value = "key", required = false) String key, HttpSession session) {
2060+
DemoParser.KEY_MAP.remove(key);
2061+
return delegate("http://localhost:3001/test/status", null, null, null, null, HttpMethod.GET, session);
2062+
}
2063+
2064+
@GetMapping("/sql/test/start")
2065+
public String startSQLTest(HttpSession session) {
2066+
long id = 100000 + Math.round(899999*Math.random());
2067+
DemoParser.KEY_MAP.put(String.valueOf(id), session); // 调这个接口一般是前端/CI/CD,调查询接口的是 Node,Session 不同 session.setAttribute("key", id);
2068+
return delegate("http://localhost:3002/test/start?key=" + id, null, null, null, null, HttpMethod.GET, session);
2069+
}
2070+
@GetMapping("/sql/test/status")
2071+
public String getSQLTestStatus(@RequestParam("key") String key, HttpSession session) {
2072+
DemoParser.KEY_MAP.remove(key);
2073+
return delegate("http://localhost:3002/test/status", null, null, null, null, HttpMethod.GET, session);
2074+
}
2075+
2076+
// 为 APIAuto, UnitAuto, SQLAuto 提供的后台 Headless 无 UI 测试转发接口 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
20482077

20492078

20502079
}

APIJSON-Java-Server/APIJSONBoot-MultiDataSource/src/main/java/apijson/demo/DemoParser.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
*/
3939
public class DemoParser extends APIJSONParser<Long> {
4040

41-
public static final Map<Long, HttpSession> KEY_MAP;
41+
public static final Map<String, HttpSession> KEY_MAP;
4242
static {
4343
KEY_MAP = new HashMap<>();
4444
}
@@ -63,7 +63,7 @@ public int getMaxQueryCount() {
6363
@Override
6464
public JSONObject parseResponse(JSONObject request) {
6565
try { // 内部使用,可通过这种方式来突破限制,获得更大的自由度
66-
HttpSession session = KEY_MAP.get(request.getLong("key"));
66+
HttpSession session = KEY_MAP.get(request.getString("key"));
6767
//DemoVerifier.verifyLogin(session);
6868
if (session != null) {
6969
request.remove("key");
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)