Skip to content

Commit 5e71493

Browse files
committed
Java: MultiDataSource 完善驼峰与蛇形命名互转的代码
1 parent f8ca8af commit 5e71493

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

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

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -189,11 +189,7 @@ public String getDBUri() {
189189
return "";
190190
}
191191

192-
@Override
193-
public String getSQLTable() {
194-
String t = super.getSQLTable();
195-
return isInfluxDB() ? t.toLowerCase() : t;
196-
}
192+
197193

198194
// TODO 迁移到 APIJSON 主项目 <<<<<<<<<<<<<<<<<<<<
199195
@Override
@@ -390,10 +386,20 @@ protected void onJoinComplexRelation(String sql, String quote, Join join, String
390386
}
391387

392388

389+
@Override
390+
public String getSQLTable() {
391+
String t = super.getSQLTable();
392+
return isInfluxDB() ? t.toLowerCase() : t;
393+
// return isInfluxDB() ? t.toLowerCase() : StringUtil.firstCase(JSONRequest.recoverUnderline(t, false), false);
394+
}
395+
393396
// 取消注释可将前端传参驼峰命名转为蛇形命名 aBCdEfg => upper ? A_B_CD_EFG : a_b_cd_efg
394397
// @Override
395398
// public String getSQLKey(String key) {
396-
// return super.getSQLKey(JSONRequest.recoverUnderline(key, false));
399+
// if (DemoVerifier.SYSTEM_ACCESS_MAP.containsKey(getTable())) {
400+
// return key;
401+
// }
402+
// return super.getSQLKey(StringUtil.firstCase(JSONRequest.recoverUnderline(key, false), false));
397403
// }
398404

399405
}

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,11 @@ public JSONObject execute(@NotNull SQLConfig<Long> config, boolean unknownType)
376376
// @Override
377377
// protected String getKey(SQLConfig<Long> config, java.sql.ResultSet rs, ResultSetMetaData rsmd, int tablePosition, JSONObject table, int columnIndex, Map<String, JSONObject> childMap) throws Exception {
378378
// String key = super.getKey(config, rs, rsmd, tablePosition, table, columnIndex, childMap);
379-
// return JSONResponse.formatUnderline(key, true);
379+
// String tbl = StringUtil.firstCase(JSONResponse.formatUnderline(rsmd.getTableName(columnIndex), true), true);
380+
// if (DemoVerifier.SYSTEM_ACCESS_MAP.containsKey(tbl)) {
381+
// return key;
382+
// }
383+
// return StringUtil.firstCase(JSONResponse.formatUnderline(key, true), false);
380384
// }
381385

382386
}

0 commit comments

Comments
 (0)