Skip to content

Commit be7d551

Browse files
committed
Java:MultiDataSource 还原流量录制/回放配置、默认端口,更新 APIAuto
1 parent f26d56d commit be7d551

File tree

4 files changed

+9
-22
lines changed

4 files changed

+9
-22
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public static void main(String[] args) throws Exception {
100100
// SpringBoot 2.x 自定义端口方式
101101
@Override
102102
public void customize(ConfigurableServletWebServerFactory server) {
103-
server.setPort(9090);
103+
server.setPort(8080);
104104
}
105105

106106
// 支持 APIAuto 中 JavaScript 代码跨域请求

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1178,7 +1178,7 @@ public void remove(String key) {
11781178
public static final int REQUEST_RECORD_TYPE_UNIT = 2;
11791179
public static final int REQUEST_RECORD_TYPE_SQL = 3;
11801180

1181-
public static Integer REQUEST_RECORD_TYPE = - REQUEST_RECORD_TYPE_API;
1181+
public static Integer REQUEST_RECORD_TYPE = 0;
11821182

11831183
@Autowired
11841184
HttpServletRequest httpServletRequest;

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,6 @@ public synchronized void removeCache(String sql, SQLConfig config) {
130130
// Redis 缓存 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
131131

132132
public static final String DATABASE_NEBULA = "NEBULA";
133-
public static final String DATABASE_SNOWFLAKE = "SNOWFLAKE";
134-
public static final String DATABASE_CASSANDRA = "CASSANDRA";
135133

136134
// 适配连接池,如果这里能拿到连接池的有效 Connection,则 SQLConfig 不需要配置 dbVersion, dbUri, dbAccount, dbPassword
137135
@Override
@@ -204,7 +202,8 @@ public Connection getConnection(SQLConfig config) throws Exception {
204202

205203
@Override
206204
public JSONObject execute(@NotNull SQLConfig config, boolean unknownType) throws Exception {
207-
if (DATABASE_CASSANDRA.equals(config.getDatabase()) || DemoSQLConfig.DATABASE_INFLUXDB.equals(config.getDatabase())) {
205+
String db = config.getDatabase();
206+
if (DemoSQLConfig.DATABASE_CASSANDRA.equals(db) || DemoSQLConfig.DATABASE_INFLUXDB.equals(db)) {
208207

209208
String sql = config.getSQL(config.isPrepared());
210209

@@ -217,7 +216,7 @@ public JSONObject execute(@NotNull SQLConfig config, boolean unknownType) throws
217216
}
218217

219218

220-
if (DATABASE_CASSANDRA.equals(config.getDatabase())) {
219+
if (DemoSQLConfig.DATABASE_CASSANDRA.equals(db)) {
221220
CqlSession session = CqlSession.builder()
222221
// .withCloudSecureConnectBundle(Paths.get("/path/to/secure-connect-database_name.zip"))
223222
.withCloudSecureConnectBundle(new URL(config.getDBUri()))
@@ -253,7 +252,7 @@ public JSONObject execute(@NotNull SQLConfig config, boolean unknownType) throws
253252
}
254253

255254

256-
if (DemoSQLConfig.DATABASE_INFLUXDB.equals(config.getDatabase())) {
255+
if (DemoSQLConfig.DATABASE_INFLUXDB.equals(db)) {
257256
InfluxDB influxDB = InfluxDBFactory.connect(config.getDBUri(), config.getDBAccount(), config.getDBPassword());
258257
influxDB.setDatabase(config.getSchema());
259258

APIJSON-Java-Server/APIJSONBoot-MultiDataSource/src/main/resources/static/js/main.js

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5000,25 +5000,13 @@ https://github.com/Tencent/APIJSON/issues
50005000
var evalPostScript = function () {}
50015001

50025002
var sendRequest = function (isAdminOperation, type, url, req, header, callback) {
5003-
var hs = ""
5004-
if (isDelegate && header != null) {
5005-
for (var k in header) {
5006-
var v = k == null ? null : header[k]
5007-
if (k == null || k.toLowerCase() == 'apijson-delegate-id') {
5008-
continue
5009-
}
5010-
hs += '\n' + k + ': ' + (v instanceof Object ? JSON.stringify(v) : v)
5011-
}
5012-
}
5013-
50145003
// axios.defaults.withcredentials = true
50155004
axios({
50165005
method: (type == REQUEST_TYPE_PARAM ? 'get' : 'post'),
5017-
url: (isDelegate ? (
5006+
url: (isDelegate
5007+
? (
50185008
App.server + '/delegate?' + (type == REQUEST_TYPE_GRPC ? '$_type=GRPC&' : '')
5019-
+ (StringUtil.isEmpty(App.delegateId, true) ? '' : '$_delegate_id=' + App.delegateId + '&')
5020-
+ '$_delegate_url=' + encodeURIComponent(url)
5021-
+ (StringUtil.isEmpty(hs, true) ? '' : '&$_headers=' + encodeURIComponent(hs.trim()))
5009+
+ (StringUtil.isEmpty(App.delegateId, true) ? '' : '$_delegate_id=' + App.delegateId + '&') + '$_delegate_url=' + encodeURIComponent(url)
50225010
) : (
50235011
App.isEncodeEnabled ? encodeURI(url) : url
50245012
)

0 commit comments

Comments
 (0)