TableConfig添加private Boolean mapperGenerateEnable = Boolean.TRUE,

当值为false,在生成代码时自动给@Table注解添加mapperGenerateEnable = false属性。
This commit is contained in:
稻草人 2023-04-18 22:54:02 +08:00
parent 0293bb4c09
commit 6afc590d16
3 changed files with 27 additions and 14 deletions

View File

@ -48,6 +48,8 @@ public class TableConfig {
private Map<String, ColumnConfig> columnConfigMap;
private Boolean mapperGenerateEnable = Boolean.TRUE;
public String getTableName() {
return tableName;
@ -105,6 +107,14 @@ public class TableConfig {
this.columnConfigMap = columnConfigMap;
}
public Boolean getMapperGenerateEnable() {
return mapperGenerateEnable;
}
public void setMapperGenerateEnable(Boolean mapperGenerateEnable) {
this.mapperGenerateEnable = mapperGenerateEnable;
}
public void addColumnConfig(ColumnConfig columnConfig) {
if (columnConfigMap == null) {
columnConfigMap = new HashMap<>();

View File

@ -117,22 +117,22 @@ public class Column {
boolean needComma = false;
if (isAutoIncrement) {
annotations.append("keyType=KeyType.Auto");
annotations.append("keyType = KeyType.Auto");
needComma = true;
} else if (columnConfig.getKeyType() != null) {
annotations.append("keyType=KeyType." + columnConfig.getKeyType().name());
annotations.append("keyType = KeyType." + columnConfig.getKeyType().name());
needComma = true;
}
if (columnConfig.getKeyValue() != null) {
addComma(annotations, needComma);
annotations.append("value=\"" + columnConfig.getKeyValue() + "\"");
annotations.append("value = \"" + columnConfig.getKeyValue() + "\"");
needComma = true;
}
if (columnConfig.getKeyBefore() != null) {
addComma(annotations, needComma);
annotations.append("before=" + columnConfig.getKeyBefore());
annotations.append("before = " + columnConfig.getKeyBefore());
}
if (annotations.length() == 4) {
@ -155,42 +155,42 @@ public class Column {
annotations.append("@Column(");
boolean needComma = false;
if (columnConfig.getOnInsertValue() != null) {
annotations.append("onInsertValue=\"" + columnConfig.getOnInsertValue() + "\"");
annotations.append("onInsertValue = \"" + columnConfig.getOnInsertValue() + "\"");
needComma = true;
}
if (columnConfig.getOnUpdateValue() != null) {
addComma(annotations, needComma);
annotations.append("onUpdateValue=\"" + columnConfig.getOnUpdateValue() + "\"");
annotations.append("onUpdateValue = \"" + columnConfig.getOnUpdateValue() + "\"");
needComma = true;
}
if (columnConfig.getLarge() != null) {
addComma(annotations, needComma);
annotations.append("isLarge=" + columnConfig.getLarge());
annotations.append("isLarge = " + columnConfig.getLarge());
needComma = true;
}
if (columnConfig.getLogicDelete() != null) {
addComma(annotations, needComma);
annotations.append("isLogicDelete=" + columnConfig.getLogicDelete());
annotations.append("isLogicDelete = " + columnConfig.getLogicDelete());
needComma = true;
}
if (columnConfig.getVersion() != null) {
addComma(annotations, needComma);
annotations.append("version=" + columnConfig.getVersion());
annotations.append("version = " + columnConfig.getVersion());
needComma = true;
}
if (columnConfig.getJdbcType() != null) {
addComma(annotations, needComma);
annotations.append("jdbcType=JdbcType." + columnConfig.getJdbcType().name());
annotations.append("jdbcType = JdbcType." + columnConfig.getJdbcType().name());
needComma = true;
}
if (columnConfig.getTypeHandler() != null) {
addComma(annotations, needComma);
annotations.append("typeHandler=" + columnConfig.getTypeHandler().getSimpleName() + ".class");
annotations.append("typeHandler = " + columnConfig.getTypeHandler().getSimpleName() + ".class");
needComma = true;
}
if (Boolean.TRUE.equals(columnConfig.getTenantId())) {
addComma(annotations, needComma);
annotations.append("tenantId=true");
annotations.append("tenantId = true");
}
annotations.append(")");
}

View File

@ -249,15 +249,18 @@ public class Table {
if (tableConfig.getSetListenerClass() != null) {
tableAnnotation.append(", onSet = " + tableConfig.getUpdateListenerClass().getSimpleName() + ".class");
}
if (Boolean.FALSE.equals(tableConfig.getMapperGenerateEnable())) {
tableAnnotation.append(", mapperGenerateEnable = false");
}
}
return tableAnnotation.append(")").toString();
}
public String buildMapperImport(){
public String buildMapperImport() {
return globalConfig.getMapperSupperClass().getName();
}
public String buildMapperName(){
public String buildMapperName() {
return globalConfig.getMapperSupperClass().getSimpleName();
}