Skip to content

Commit c6b101f

Browse files
committed
新增支持自定义 APIJSON 配置表对应的数据库类型
1 parent 871e2ee commit c6b101f

1 file changed

Lines changed: 15 additions & 3 deletions

File tree

src/main/java/apijson/framework/APIJSONSQLConfig.java

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ public String getDBVersion() {
102102
return null;
103103
}
104104

105+
@JSONField(serialize = false) // 不在日志打印 账号/密码 等敏感信息,用了 UnitAuto 则一定要加
105106
@Override
106107
public String getDBUri() {
107108
if (isMySQL()) {
@@ -119,7 +120,7 @@ public String getDBUri() {
119120
return null;
120121
}
121122

122-
@JSONField(serialize = false) // 不在日志打印 账号/密码 等敏感信息
123+
@JSONField(serialize = false) // 不在日志打印 账号/密码 等敏感信息,用了 UnitAuto 则一定要加
123124
@Override
124125
public String getDBAccount() {
125126
if (isMySQL()) {
@@ -137,7 +138,7 @@ public String getDBAccount() {
137138
return null;
138139
}
139140

140-
@JSONField(serialize = false) // 不在日志打印 账号/密码 等敏感信息
141+
@JSONField(serialize = false) // 不在日志打印 账号/密码 等敏感信息,用了 UnitAuto 则一定要加
141142
@Override
142143
public String getDBPassword() {
143144
if (isMySQL()) {
@@ -180,19 +181,30 @@ public String getDBPassword() {
180181
// return false;
181182
// }
182183

184+
/**获取 APIJSON 配置表所在数据库模式 database,默认与业务表一块
185+
* @return
186+
*/
187+
public String getConfigDatabase() {
188+
return getDatabase();
189+
}
183190
/**获取 APIJSON 配置表所在数据库模式 schema,默认与业务表一块
184191
* @return
185192
*/
186193
public String getConfigSchema() {
187194
return getSchema();
188195
}
189-
/**是否为 APIJSON 配置表
196+
/**是否为 APIJSON 配置表,如果和业务表一块,可以重写这个方法,固定 return false 来提高性能
190197
* @return
191198
*/
192199
public boolean isConfigTable() {
193200
return CONFIG_TABLE_LIST.contains(getTable());
194201
}
195202
@Override
203+
public String getSQLDatabase() {
204+
String db = isConfigTable() ? getConfigDatabase() : super.getSQLDatabase();
205+
return db == null ? DEFAULT_DATABASE : db;
206+
}
207+
@Override
196208
public String getSQLSchema() {
197209
String sch = isConfigTable() ? getConfigSchema() : super.getSQLSchema();
198210
return sch == null ? DEFAULT_SCHEMA : sch;

0 commit comments

Comments
 (0)