mirror of
https://gitee.com/mybatis-flex/mybatis-flex.git
synced 2025-12-08 09:38:26 +08:00
refactor: optimize TableInfo.setTableName
This commit is contained in:
parent
4af6863b82
commit
b325882a35
@ -150,7 +150,17 @@ public class TableInfo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setTableName(String tableName) {
|
public void setTableName(String tableName) {
|
||||||
this.tableName = tableName;
|
int indexOf = tableName.indexOf(".");
|
||||||
|
if (indexOf > 0) {
|
||||||
|
if (StringUtil.isBlank(schema)) {
|
||||||
|
this.schema = tableName.substring(0, indexOf);
|
||||||
|
this.tableName = tableName.substring(indexOf + 1);
|
||||||
|
} else {
|
||||||
|
this.tableName = tableName;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
this.tableName = tableName;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Class<?> getEntityClass() {
|
public Class<?> getEntityClass() {
|
||||||
|
|||||||
@ -134,8 +134,8 @@ public class TableInfoFactory {
|
|||||||
//初始化表名
|
//初始化表名
|
||||||
Table table = entityClass.getAnnotation(Table.class);
|
Table table = entityClass.getAnnotation(Table.class);
|
||||||
if (table != null) {
|
if (table != null) {
|
||||||
tableInfo.setTableName(table.value());
|
|
||||||
tableInfo.setSchema(table.schema());
|
tableInfo.setSchema(table.schema());
|
||||||
|
tableInfo.setTableName(table.value());
|
||||||
tableInfo.setCamelToUnderline(table.camelToUnderline());
|
tableInfo.setCamelToUnderline(table.camelToUnderline());
|
||||||
|
|
||||||
if (table.onInsert().length > 0) {
|
if (table.onInsert().length > 0) {
|
||||||
|
|||||||
@ -180,8 +180,8 @@ public class MybatisFlexProcessor extends AbstractProcessor {
|
|||||||
TableInfo tableInfo = new TableInfo();
|
TableInfo tableInfo = new TableInfo();
|
||||||
tableInfo.setEntityName(entityClass);
|
tableInfo.setEntityName(entityClass);
|
||||||
tableInfo.setEntitySimpleName(entityClassName);
|
tableInfo.setEntitySimpleName(entityClassName);
|
||||||
tableInfo.setTableName(table.value());
|
|
||||||
tableInfo.setSchema(table.schema());
|
tableInfo.setSchema(table.schema());
|
||||||
|
tableInfo.setTableName(table.value());
|
||||||
tableInfo.setEntityComment(elementUtils.getDocComment(entityClassElement));
|
tableInfo.setEntityComment(elementUtils.getDocComment(entityClassElement));
|
||||||
|
|
||||||
// 生成 TableDef 文件
|
// 生成 TableDef 文件
|
||||||
|
|||||||
@ -78,7 +78,17 @@ public class TableInfo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setTableName(String tableName) {
|
public void setTableName(String tableName) {
|
||||||
this.tableName = tableName;
|
int indexOf = tableName.indexOf(".");
|
||||||
|
if (indexOf > 0) {
|
||||||
|
if (schema == null || schema.trim().length() == 0) {
|
||||||
|
this.schema = tableName.substring(0, indexOf);
|
||||||
|
this.tableName = tableName.substring(indexOf + 1);
|
||||||
|
} else {
|
||||||
|
this.tableName = tableName;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
this.tableName = tableName;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getSchema() {
|
public String getSchema() {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user