ColumnConfig添加tenantId字段,用于代码生成时添加@Column(tenantId=true)注解

This commit is contained in:
稻草人 2023-04-18 22:26:02 +08:00
parent eda42f60d5
commit 0293bb4c09
3 changed files with 24 additions and 3 deletions

View File

@ -42,6 +42,8 @@ public class ColumnConfig implements Serializable {
private String keyValue;
private Boolean keyBefore;
private Boolean tenantId;
public String getColumnName() {
return columnName;
@ -146,4 +148,12 @@ public class ColumnConfig implements Serializable {
public void setKeyBefore(Boolean keyBefore) {
this.keyBefore = keyBefore;
}
public Boolean getTenantId() {
return tenantId;
}
public void setTenantId(Boolean tenantId) {
this.tenantId = tenantId;
}
}

View File

@ -150,6 +150,7 @@ public class Column {
|| columnConfig.getVersion() != null
|| columnConfig.getJdbcType() != null
|| columnConfig.getTypeHandler() != null
|| columnConfig.getTenantId() != null
) {
annotations.append("@Column(");
boolean needComma = false;
@ -185,6 +186,11 @@ public class Column {
if (columnConfig.getTypeHandler() != null) {
addComma(annotations, needComma);
annotations.append("typeHandler=" + columnConfig.getTypeHandler().getSimpleName() + ".class");
needComma = true;
}
if (Boolean.TRUE.equals(columnConfig.getTenantId())) {
addComma(annotations, needComma);
annotations.append("tenantId=true");
}
annotations.append(")");
}
@ -194,7 +200,11 @@ public class Column {
annotations.append("@ColumnMask(\"" + columnConfig.getMask() + "\")");
}
return annotations.toString();
String result = annotations.toString();
if (!result.isEmpty()) {
result += "\n ";
}
return result;
}
private void addComma(StringBuilder annotations, boolean needComma) {
@ -242,6 +252,7 @@ public class Column {
|| columnConfig.getVersion() != null
|| columnConfig.getJdbcType() != null
|| columnConfig.getTypeHandler() != null
|| Boolean.TRUE.equals(columnConfig.getTenantId())
) {
importClasses.add(com.mybatisflex.annotation.Column.class.getName());
}

View File

@ -7,9 +7,9 @@ import #(importClass);
#(table.buildTableAnnotation())
public class #(table.buildEntityClassName())#(table.buildExtends())#(table.buildImplements()) {
#for(column: table.columns)
#for(column: table.columns) #(column.buildAnnotations())
private #(column.propertySimpleType) #(column.property);
#(column.buildAnnotations())private #(column.propertySimpleType) #(column.property);
#end
#if(!globalConfig.isEntityWithLombok())