update 优化 代码生成器数字类别判断
This commit is contained in:
parent
90328ae79b
commit
1b8c9fdaa9
@ -37,8 +37,6 @@ public class GenUtils {
|
|||||||
public static void initColumnField(GenTableColumn column, GenTable table) {
|
public static void initColumnField(GenTableColumn column, GenTable table) {
|
||||||
String dataType = getDbType(column.getColumnType());
|
String dataType = getDbType(column.getColumnType());
|
||||||
String columnName = column.getColumnName();
|
String columnName = column.getColumnName();
|
||||||
column.setTableId(table.getTableId());
|
|
||||||
column.setCreateBy(table.getCreateBy());
|
|
||||||
// 设置java字段名
|
// 设置java字段名
|
||||||
column.setJavaField(StringUtils.toCamelCase(columnName));
|
column.setJavaField(StringUtils.toCamelCase(columnName));
|
||||||
// 设置默认类型
|
// 设置默认类型
|
||||||
@ -55,21 +53,10 @@ public class GenUtils {
|
|||||||
column.setHtmlType(GenConstants.HTML_DATETIME);
|
column.setHtmlType(GenConstants.HTML_DATETIME);
|
||||||
} else if (arraysContains(GenConstants.COLUMNTYPE_NUMBER, dataType)) {
|
} else if (arraysContains(GenConstants.COLUMNTYPE_NUMBER, dataType)) {
|
||||||
column.setHtmlType(GenConstants.HTML_INPUT);
|
column.setHtmlType(GenConstants.HTML_INPUT);
|
||||||
|
// 数据库的数字字段与java不匹配 且很多数据库的数字字段很模糊 例如oracle只有number没有细分
|
||||||
// 如果是浮点型 统一用BigDecimal
|
// 所以默认数字类型全为Long可在界面上自行编辑想要的类型 有什么特殊需求也可以在这里特殊处理
|
||||||
String[] str = StringUtils.split(StringUtils.substringBetween(column.getColumnType(), "(", ")"), StringUtils.SEPARATOR);
|
|
||||||
if (str != null && str.length == 2 && Integer.parseInt(str[1]) > 0) {
|
|
||||||
column.setJavaType(GenConstants.TYPE_BIGDECIMAL);
|
|
||||||
}
|
|
||||||
// 如果是整形
|
|
||||||
else if (str != null && str.length == 1 && Integer.parseInt(str[0]) <= 10) {
|
|
||||||
column.setJavaType(GenConstants.TYPE_INTEGER);
|
|
||||||
}
|
|
||||||
// 长整形
|
|
||||||
else {
|
|
||||||
column.setJavaType(GenConstants.TYPE_LONG);
|
column.setJavaType(GenConstants.TYPE_LONG);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// BO对象 默认插入勾选
|
// BO对象 默认插入勾选
|
||||||
if (!arraysContains(GenConstants.COLUMNNAME_NOT_ADD, columnName) && !column.isPk()) {
|
if (!arraysContains(GenConstants.COLUMNNAME_NOT_ADD, columnName) && !column.isPk()) {
|
||||||
@ -79,10 +66,6 @@ public class GenUtils {
|
|||||||
if (!arraysContains(GenConstants.COLUMNNAME_NOT_EDIT, columnName)) {
|
if (!arraysContains(GenConstants.COLUMNNAME_NOT_EDIT, columnName)) {
|
||||||
column.setIsEdit(GenConstants.REQUIRE);
|
column.setIsEdit(GenConstants.REQUIRE);
|
||||||
}
|
}
|
||||||
// BO对象 默认是否必填勾选
|
|
||||||
if (!arraysContains(GenConstants.COLUMNNAME_NOT_EDIT, columnName)) {
|
|
||||||
column.setIsRequired(GenConstants.REQUIRE);
|
|
||||||
}
|
|
||||||
// VO对象 默认返回勾选
|
// VO对象 默认返回勾选
|
||||||
if (!arraysContains(GenConstants.COLUMNNAME_NOT_LIST, columnName)) {
|
if (!arraysContains(GenConstants.COLUMNNAME_NOT_LIST, columnName)) {
|
||||||
column.setIsList(GenConstants.REQUIRE);
|
column.setIsList(GenConstants.REQUIRE);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user