Merge remote-tracking branch 'gitee/main'

This commit is contained in:
Michael Yang 2025-03-17 09:17:21 +08:00
commit 1987df70a5
3 changed files with 34 additions and 4 deletions

View File

@ -110,6 +110,11 @@ public class FlexGlobalConfig {
*/ */
private String versionColumn; private String versionColumn;
/**
* 全局忽略 @Table 中配置的 schema
*/
private boolean ignoreSchema = false;
/** /**
* 未匹配列处理器 * 未匹配列处理器
*/ */
@ -329,6 +334,14 @@ public class FlexGlobalConfig {
this.versionColumn = versionColumn; this.versionColumn = versionColumn;
} }
public boolean isIgnoreSchema() {
return ignoreSchema;
}
public void setIgnoreSchema(boolean ignoreSchema) {
this.ignoreSchema = ignoreSchema;
}
public UnMappedColumnHandler getUnMappedColumnHandler() { public UnMappedColumnHandler getUnMappedColumnHandler() {
return unMappedColumnHandler; return unMappedColumnHandler;
} }

View File

@ -235,6 +235,8 @@ public class TableInfoFactory {
Reflector reflector = Reflectors.of(entityClass); Reflector reflector = Reflectors.of(entityClass);
tableInfo.setReflector(reflector); tableInfo.setReflector(reflector);
FlexGlobalConfig config = FlexGlobalConfig.getDefaultConfig();
// 初始化表名 // 初始化表名
Table table = entityClass.getAnnotation(Table.class); Table table = entityClass.getAnnotation(Table.class);
if (table == null) { if (table == null) {
@ -242,7 +244,9 @@ public class TableInfoFactory {
if (vo != null) { if (vo != null) {
TableInfo refTableInfo = ofEntityClass(vo.value()); TableInfo refTableInfo = ofEntityClass(vo.value());
// 设置 VO 类对应的真实的表名 // 设置 VO 类对应的真实的表名
tableInfo.setSchema(refTableInfo.getSchema()); if (!config.isIgnoreSchema()) {
tableInfo.setSchema(refTableInfo.getSchema());
}
tableInfo.setTableName(refTableInfo.getTableName()); tableInfo.setTableName(refTableInfo.getTableName());
// @Table 注解的属性复制到 VO 类当中 // @Table 注解的属性复制到 VO 类当中
if (vo.copyTableProps()) { if (vo.copyTableProps()) {
@ -260,7 +264,9 @@ public class TableInfoFactory {
tableInfo.setTableName(tableName); tableInfo.setTableName(tableName);
} }
} else { } else {
tableInfo.setSchema(table.schema()); if (!config.isIgnoreSchema()) {
tableInfo.setSchema(table.schema());
}
tableInfo.setTableName(table.value()); tableInfo.setTableName(table.value());
tableInfo.setCamelToUnderline(table.camelToUnderline()); tableInfo.setCamelToUnderline(table.camelToUnderline());
tableInfo.setComment(table.comment()); tableInfo.setComment(table.comment());
@ -317,8 +323,6 @@ public class TableInfoFactory {
List<Field> entityFields = getColumnFields(entityClass); List<Field> entityFields = getColumnFields(entityClass);
FlexGlobalConfig config = FlexGlobalConfig.getDefaultConfig();
TypeHandlerRegistry typeHandlerRegistry = null; TypeHandlerRegistry typeHandlerRegistry = null;
if (config.getConfiguration() != null) { if (config.getConfiguration() != null) {
typeHandlerRegistry = config.getConfiguration().getTypeHandlerRegistry(); typeHandlerRegistry = config.getConfiguration().getTypeHandlerRegistry();

View File

@ -823,6 +823,10 @@ public class MybatisFlexProperties {
*/ */
private String versionColumn; private String versionColumn;
/**
* 全局忽略 @Table 中配置的 schema
*/
private boolean ignoreSchema = false;
public boolean isPrintBanner() { public boolean isPrintBanner() {
return printBanner; return printBanner;
@ -896,6 +900,14 @@ public class MybatisFlexProperties {
this.versionColumn = versionColumn; this.versionColumn = versionColumn;
} }
public boolean isIgnoreSchema() {
return ignoreSchema;
}
public void setIgnoreSchema(boolean ignoreSchema) {
this.ignoreSchema = ignoreSchema;
}
void applyTo(FlexGlobalConfig target) { void applyTo(FlexGlobalConfig target) {
PropertyMapper mapper = PropertyMapper.get().alwaysApplyingWhenNonNull(); PropertyMapper mapper = PropertyMapper.get().alwaysApplyingWhenNonNull();
mapper.from(isPrintBanner()).to(target::setPrintBanner); mapper.from(isPrintBanner()).to(target::setPrintBanner);
@ -907,6 +919,7 @@ public class MybatisFlexProperties {
mapper.from(getLogicDeleteColumn()).to(target::setLogicDeleteColumn); mapper.from(getLogicDeleteColumn()).to(target::setLogicDeleteColumn);
mapper.from(getVersionColumn()).to(target::setVersionColumn); mapper.from(getVersionColumn()).to(target::setVersionColumn);
mapper.from(getTenantColumn()).to(target::setTenantColumn); mapper.from(getTenantColumn()).to(target::setTenantColumn);
mapper.from(isIgnoreSchema()).to(target::setIgnoreSchema);
} }
} }