更改生成器初始化列属性字段时判断具体的数字类型的方式
1. 增加了数据库数字类型常量 2. 修改了初始化列属性字段中判断具体的数字类型的方式
This commit is contained in:
parent
68a616d7c7
commit
4f78f9ec4c
@ -41,8 +41,8 @@ public class GenConstants
|
|||||||
public static final String[] COLUMNTYPE_TIME = { "datetime", "time", "date", "timestamp" };
|
public static final String[] COLUMNTYPE_TIME = { "datetime", "time", "date", "timestamp" };
|
||||||
|
|
||||||
/** 数据库数字类型 */
|
/** 数据库数字类型 */
|
||||||
public static final String[] COLUMNTYPE_NUMBER = { "tinyint", "smallint", "mediumint", "int", "number", "integer",
|
public static final String[] COLUMNTYPE_NUMBER = { "bigint", "tinyint", "smallint", "mediumint", "int", "integer", "bit",
|
||||||
"bit", "bigint", "float", "double", "decimal" };
|
"number", "numeric", "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" };
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
package com.ruoyi.generator.util;
|
package com.ruoyi.generator.util;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.ArrayUtils;
|
||||||
import org.apache.commons.lang3.RegExUtils;
|
import org.apache.commons.lang3.RegExUtils;
|
||||||
import com.ruoyi.common.constant.GenConstants;
|
import com.ruoyi.common.constant.GenConstants;
|
||||||
import com.ruoyi.common.utils.StringUtils;
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
@ -60,14 +62,13 @@ public class GenUtils
|
|||||||
{
|
{
|
||||||
column.setHtmlType(GenConstants.HTML_INPUT);
|
column.setHtmlType(GenConstants.HTML_INPUT);
|
||||||
|
|
||||||
|
int index = ArrayUtils.indexOf(GenConstants.COLUMNTYPE_NUMBER, dataType);
|
||||||
// 如果是浮点型 统一用BigDecimal
|
// 如果是浮点型 统一用BigDecimal
|
||||||
String[] str = StringUtils.split(StringUtils.substringBetween(column.getColumnType(), "(", ")"), ",");
|
if (index > 6) {
|
||||||
if (str != null && str.length == 2 && Integer.parseInt(str[1]) > 0)
|
|
||||||
{
|
|
||||||
column.setJavaType(GenConstants.TYPE_BIGDECIMAL);
|
column.setJavaType(GenConstants.TYPE_BIGDECIMAL);
|
||||||
}
|
}
|
||||||
// 如果是整形
|
// 如果是整形
|
||||||
else if (str != null && str.length == 1 && Integer.parseInt(str[0]) <= 10)
|
else if (index > 0)
|
||||||
{
|
{
|
||||||
column.setJavaType(GenConstants.TYPE_INTEGER);
|
column.setJavaType(GenConstants.TYPE_INTEGER);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user