From 4cc0e2650c57cef6606e70c4c7c9198b98b7dc94 Mon Sep 17 00:00:00 2001 From: RuoYi Date: Tue, 29 Dec 2020 11:27:58 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E7=94=9F=E6=88=90=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E5=BA=93=E6=96=87=E6=9C=AC=E7=B1=BB=E5=9E=8B=E7=94=9F?= =?UTF-8?q?=E6=88=90=E8=A1=A8=E5=8D=95=E6=96=87=E6=9C=AC=E5=9F=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/ruoyi/common/core/constant/GenConstants.java | 6 ++++-- .../ruoyi-gen/src/main/java/com/ruoyi/gen/util/GenUtils.java | 7 ++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/constant/GenConstants.java b/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/constant/GenConstants.java index 29f21ee..69e81ef 100644 --- a/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/constant/GenConstants.java +++ b/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/constant/GenConstants.java @@ -29,8 +29,10 @@ public class GenConstants public static final String PARENT_MENU_NAME = "parentMenuName"; /** 数据库字符串类型 */ - public static final String[] COLUMNTYPE_STR = { "char", "varchar", "nvarchar", "varchar2", "tinytext", "text", - "mediumtext", "longtext" }; + public static final String[] COLUMNTYPE_STR = { "char", "varchar", "nvarchar", "varchar2" }; + + /** 数据库文本类型 */ + public static final String[] COLUMNTYPE_TEXT = { "tinytext", "text", "mediumtext", "longtext" }; /** 数据库时间类型 */ public static final String[] COLUMNTYPE_TIME = { "datetime", "time", "date", "timestamp" }; diff --git a/ruoyi-modules/ruoyi-gen/src/main/java/com/ruoyi/gen/util/GenUtils.java b/ruoyi-modules/ruoyi-gen/src/main/java/com/ruoyi/gen/util/GenUtils.java index f386058..8150270 100644 --- a/ruoyi-modules/ruoyi-gen/src/main/java/com/ruoyi/gen/util/GenUtils.java +++ b/ruoyi-modules/ruoyi-gen/src/main/java/com/ruoyi/gen/util/GenUtils.java @@ -40,13 +40,14 @@ public class GenUtils column.setCreateBy(table.getCreateBy()); // 设置java字段名 column.setJavaField(StringUtils.toCamelCase(columnName)); + // 设置默认类型 + column.setJavaType(GenConstants.TYPE_STRING); - if (arraysContains(GenConstants.COLUMNTYPE_STR, dataType)) + if (arraysContains(GenConstants.COLUMNTYPE_STR, dataType) || arraysContains(GenConstants.COLUMNTYPE_TEXT, dataType)) { - column.setJavaType(GenConstants.TYPE_STRING); // 字符串长度超过500设置为文本域 Integer columnLength = getColumnLength(column.getColumnType()); - String htmlType = columnLength >= 500 ? GenConstants.HTML_TEXTAREA : GenConstants.HTML_INPUT; + String htmlType = columnLength >= 500 || arraysContains(GenConstants.COLUMNTYPE_TEXT, dataType) ? GenConstants.HTML_TEXTAREA : GenConstants.HTML_INPUT; column.setHtmlType(htmlType); } else if (arraysContains(GenConstants.COLUMNTYPE_TIME, dataType))