修复代码生成数字类型无效均为long,mysql8.0.27使用下
This commit is contained in:
parent
9f7acd4cf9
commit
4d8890d4b3
ruoyi-common/src/main/java/com/ruoyi/common/constant
ruoyi-generator/src/main/java/com/ruoyi/generator/util
@ -44,6 +44,18 @@ public class GenConstants
|
|||||||
public static final String[] COLUMNTYPE_NUMBER = { "tinyint", "smallint", "mediumint", "int", "number", "integer",
|
public static final String[] COLUMNTYPE_NUMBER = { "tinyint", "smallint", "mediumint", "int", "number", "integer",
|
||||||
"bit", "bigint", "float", "double", "decimal" };
|
"bit", "bigint", "float", "double", "decimal" };
|
||||||
|
|
||||||
|
/** 数据库数字类型 */
|
||||||
|
public static final String[] COLUMNTYPE_NUMBER_BIT = { "bit" };
|
||||||
|
|
||||||
|
/** 数据库数字类型 */
|
||||||
|
public static final String[] COLUMNTYPE_NUMBER_INT = { "tinyint", "smallint", "mediumint", "int", "number", "integer" };
|
||||||
|
|
||||||
|
/** 数据库数字类型 */
|
||||||
|
public static final String[] COLUMNTYPE_NUMBER_LONG = { "bigint" };
|
||||||
|
|
||||||
|
/** 数据库数字类型 */
|
||||||
|
public static final String[] COLUMNTYPE_NUMBER_REAL = { "float", "double", "decimal" };
|
||||||
|
|
||||||
/** 页面不需要编辑字段 */
|
/** 页面不需要编辑字段 */
|
||||||
public static final String[] COLUMNNAME_NOT_EDIT = { "id", "create_by", "create_time", "del_flag" };
|
public static final String[] COLUMNNAME_NOT_EDIT = { "id", "create_by", "create_time", "del_flag" };
|
||||||
|
|
||||||
@ -88,6 +100,9 @@ public class GenConstants
|
|||||||
/** 富文本控件 */
|
/** 富文本控件 */
|
||||||
public static final String HTML_EDITOR = "editor";
|
public static final String HTML_EDITOR = "editor";
|
||||||
|
|
||||||
|
/** 布尔类型 */
|
||||||
|
public static final String TYPE_BOOLEAN = "Boolean";
|
||||||
|
|
||||||
/** 字符串类型 */
|
/** 字符串类型 */
|
||||||
public static final String TYPE_STRING = "String";
|
public static final String TYPE_STRING = "String";
|
||||||
|
|
||||||
|
@ -55,26 +55,25 @@ public class GenUtils
|
|||||||
column.setJavaType(GenConstants.TYPE_DATE);
|
column.setJavaType(GenConstants.TYPE_DATE);
|
||||||
column.setHtmlType(GenConstants.HTML_DATETIME);
|
column.setHtmlType(GenConstants.HTML_DATETIME);
|
||||||
}
|
}
|
||||||
else if (arraysContains(GenConstants.COLUMNTYPE_NUMBER, dataType))
|
else if (arraysContains(GenConstants.COLUMNTYPE_NUMBER_INT, dataType))
|
||||||
{
|
{
|
||||||
column.setHtmlType(GenConstants.HTML_INPUT);
|
column.setHtmlType(GenConstants.HTML_INPUT);
|
||||||
|
column.setJavaType(GenConstants.TYPE_INTEGER);
|
||||||
// 如果是浮点型 统一用BigDecimal
|
}
|
||||||
String[] str = StringUtils.split(StringUtils.substringBetween(column.getColumnType(), "(", ")"), ",");
|
else if (arraysContains(GenConstants.COLUMNTYPE_NUMBER_LONG, dataType))
|
||||||
if (str != null && str.length == 2 && Integer.parseInt(str[1]) > 0)
|
{
|
||||||
{
|
column.setHtmlType(GenConstants.HTML_INPUT);
|
||||||
column.setJavaType(GenConstants.TYPE_BIGDECIMAL);
|
column.setJavaType(GenConstants.TYPE_LONG);
|
||||||
}
|
}
|
||||||
// 如果是整形
|
else if (arraysContains(GenConstants.COLUMNTYPE_NUMBER_REAL, dataType))
|
||||||
else if (str != null && str.length == 1 && Integer.parseInt(str[0]) <= 10)
|
{
|
||||||
{
|
column.setHtmlType(GenConstants.HTML_INPUT);
|
||||||
column.setJavaType(GenConstants.TYPE_INTEGER);
|
column.setJavaType(GenConstants.TYPE_BIGDECIMAL);
|
||||||
}
|
}
|
||||||
// 长整形
|
else if (arraysContains(GenConstants.COLUMNTYPE_NUMBER_BIT, dataType))
|
||||||
else
|
{
|
||||||
{
|
column.setHtmlType(GenConstants.HTML_RADIO);
|
||||||
column.setJavaType(GenConstants.TYPE_LONG);
|
column.setJavaType(GenConstants.TYPE_BIGDECIMAL);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 插入字段(默认所有字段都需要插入)
|
// 插入字段(默认所有字段都需要插入)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user