feat(tool/generator): 代码生成 Request 实体时,针对字符串类型增加数据长度校验注解

This commit is contained in:
2024-01-06 21:02:31 +08:00
parent e3e958b419
commit ee8255876f
5 changed files with 16 additions and 4 deletions

View File

@@ -77,6 +77,12 @@ public class FieldConfigDO implements Serializable {
@NotBlank(message = "列类型不能为空")
private String columnType;
/**
* 列大小
*/
@Schema(description = "列大小", example = "255")
private Long columnSize;
/**
* 字段名称
*/
@@ -147,6 +153,7 @@ public class FieldConfigDO implements Serializable {
this.tableName = column.getTableName();
this.setColumnName(column.getName());
this.setColumnType(columnType);
this.setColumnSize(column.getSize());
this.setComment(column.getComment());
this.setIsRequired(isRequired);
this.setShowInList(true);

View File

@@ -138,7 +138,6 @@ public class GeneratorServiceImpl implements GeneratorService {
Collection<Column> columnList = MetaUtils.getColumns(dataSource, tableName);
return columnList.stream().map(FieldConfigDO::new).collect(Collectors.toList());
}
// 同步最新数据表列信息
if (requireSync) {
Collection<Column> columnList = MetaUtils.getColumns(dataSource, tableName);
@@ -155,6 +154,7 @@ public class GeneratorServiceImpl implements GeneratorService {
String columnType =
StrUtil.splitToArray(column.getTypeName(), StringConstants.SPACE)[0].toLowerCase();
fieldConfig.setColumnType(columnType);
fieldConfig.setColumnSize(column.getSize());
fieldConfig.setComment(column.getComment());
} else {
// 新增字段配置
@@ -193,7 +193,6 @@ public class GeneratorServiceImpl implements GeneratorService {
fieldConfig.setTableName(tableName);
}
fieldConfigMapper.insertBatch(fieldConfigList);
// 保存或更新生成配置信息
GenConfigDO newGenConfig = req.getGenConfig();
String frontendPath = newGenConfig.getFrontendPath();