mirror of
https://gitee.com/mybatis-flex/mybatis-flex.git
synced 2025-12-08 17:48:25 +08:00
feat: add 代码生成器 StrategyConfig 增加ignoreColumns, 用于在Entity生成时,可以忽略部分字段.
This commit is contained in:
parent
86525f16e1
commit
d641947d4e
@ -76,6 +76,31 @@ public class StrategyConfig {
|
|||||||
*/
|
*/
|
||||||
private Set<String> unGenerateTables;
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置要生成的模式
|
* 设置要生成的模式
|
||||||
|
|||||||
@ -131,6 +131,12 @@ public class Table {
|
|||||||
|
|
||||||
public void addColumn(Column column) {
|
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())) {
|
if (primaryKeys != null && primaryKeys.contains(column.getName())) {
|
||||||
column.setPrimaryKey(true);
|
column.setPrimaryKey(true);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user