!176 代码生成器 ColumnConfig 增加 propertyType. 可以用于自定通用属性的类型,StrategyConfig 增加ignoreColumns, 用于在Entity生成时,可以忽略部分字段.。

Merge pull request !176 from Jerry_Zheng/main
This commit is contained in:
Michael Yang 2023-07-24 23:11:52 +00:00 committed by Gitee
commit 1cd367236c
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
4 changed files with 51 additions and 2 deletions

View File

@ -60,6 +60,10 @@ public class ColumnConfig implements Serializable {
* 配置的 jdbcType
*/
private JdbcType jdbcType;
/**
* 属性的类型
*/
private Class<?> propertyType;
/**
* 自定义 TypeHandler
@ -207,5 +211,11 @@ public class ColumnConfig implements Serializable {
public void setTenantId(Boolean tenantId) {
this.tenantId = tenantId;
}
public Class<?> getPropertyType() {
return propertyType;
}
public void setPropertyType(Class<?> propertyType) {
this.propertyType = propertyType;
}
}

View File

@ -76,6 +76,31 @@ public class StrategyConfig {
*/
private Set<String> unGenerateTables;
/**
* 需要忽略的列 全局配置
*/
private Set<String> ignoreColumns;
/**
* 获取需要忽略的列 全局配置
*/
public Set<String> getIgnoreColumns() {
return ignoreColumns;
}
/**
* 设置需要忽略的列 全局配置
*/
public StrategyConfig setIgnoreColumns(String... columns) {
if (ignoreColumns == null) {
ignoreColumns = new HashSet<>();
}
for (String column : columns) {
if (column != null && column.trim().length() > 0) {
ignoreColumns.add(column.trim().toLowerCase());
}
}
return this;
}
/**
* 设置要生成的模式

View File

@ -93,7 +93,12 @@ public class Column {
}
public String getPropertySimpleType() {
return propertyType.substring(propertyType.lastIndexOf(".") + 1);
if (columnConfig.getPropertyType()!=null){
return columnConfig.getPropertyType().getSimpleName();
}
else {
return propertyType.substring(propertyType.lastIndexOf(".") + 1);
}
}
public void setPropertyType(String propertyType) {
@ -291,6 +296,9 @@ public class Column {
}
if (columnConfig != null) {
if (columnConfig.getPropertyType() !=null){
importClasses.add(columnConfig.getPropertyType().getName());
}
if (columnConfig.getMask() != null) {
importClasses.add(ColumnMask.class.getName());
}

View File

@ -131,6 +131,12 @@ public class Table {
public void addColumn(Column column) {
//排除忽略列
if (globalConfig.getStrategyConfig().getIgnoreColumns() != null &&
globalConfig.getStrategyConfig().getIgnoreColumns().contains(column.getName().toLowerCase())) {
return;
}
//主键
if (primaryKeys != null && primaryKeys.contains(column.getName())) {
column.setPrimaryKey(true);