fix: 策略中的 schema 和 tableConfig 中的 schema 冲突问题,以 tableConfig 中配置的 schema 为主。

This commit is contained in:
Suomm 2023-06-22 13:02:27 +08:00
parent 4a604c3bf7
commit ebfdae3d14

View File

@ -203,14 +203,27 @@ public class Table {
tableAnnotation.append("@Table(value = \"").append(name).append("\""); tableAnnotation.append("@Table(value = \"").append(name).append("\"");
if (StringUtil.isNotBlank(schema)) { String globalSchema;
tableAnnotation.append(", schema = \"").append(schema).append("\"");
if (tableConfig == null) {
// 未配置 tableConfig 以策略中的 schema 为主
globalSchema = schema;
} else if (StringUtil.isBlank(tableConfig.getSchema())) {
// 配置 tableConfig 但未指定 schema 还是以策略中的 schema 为主
globalSchema = schema;
} else {
// 以用户设置的 tableConfig 中的 schema 为主
globalSchema = null;
}
if (StringUtil.isNotBlank(globalSchema)) {
tableAnnotation.append(", schema = \"").append(globalSchema).append("\"");
} }
if (tableConfig != null) { if (tableConfig != null) {
// if (tableConfig.getSchema() != null) { if (StringUtil.isNotBlank(tableConfig.getSchema())) {
// tableAnnotation.append(", schema = \"").append(tableConfig.getSchema()).append("\""); tableAnnotation.append(", schema = \"").append(tableConfig.getSchema()).append("\"");
// } }
if (tableConfig.getCamelToUnderline() != null) { if (tableConfig.getCamelToUnderline() != null) {
tableAnnotation.append(", camelToUnderline = \"").append(tableConfig.getCamelToUnderline()).append("\""); tableAnnotation.append(", camelToUnderline = \"").append(tableConfig.getCamelToUnderline()).append("\"");
} }