Commit 63992ac9068caebd43408f402f1cbab85d94addc

Authored by RuoYi
1 parent 01873447

代码生成数据库文本类型生成表单文本域

ruoyi-common/src/main/java/com/ruoyi/common/constant/GenConstants.java
... ... @@ -29,8 +29,10 @@ public class GenConstants
29 29 public static final String PARENT_MENU_NAME = "parentMenuName";
30 30  
31 31 /** 数据库字符串类型 */
32   - public static final String[] COLUMNTYPE_STR = { "char", "varchar", "nvarchar", "varchar2", "tinytext", "text",
33   - "mediumtext", "longtext" };
  32 + public static final String[] COLUMNTYPE_STR = { "char", "varchar", "nvarchar", "varchar2" };
  33 +
  34 + /** 数据库文本类型 */
  35 + public static final String[] COLUMNTYPE_TEXT = { "tinytext", "text", "mediumtext", "longtext" };
34 36  
35 37 /** 数据库时间类型 */
36 38 public static final String[] COLUMNTYPE_TIME = { "datetime", "time", "date", "timestamp" };
... ...
ruoyi-generator/src/main/java/com/ruoyi/generator/util/GenUtils.java
... ... @@ -40,13 +40,14 @@ public class GenUtils
40 40 column.setCreateBy(table.getCreateBy());
41 41 // 设置java字段名
42 42 column.setJavaField(StringUtils.toCamelCase(columnName));
  43 + // 设置默认类型
  44 + column.setJavaType(GenConstants.TYPE_STRING);
43 45  
44   - if (arraysContains(GenConstants.COLUMNTYPE_STR, dataType))
  46 + if (arraysContains(GenConstants.COLUMNTYPE_STR, dataType) || arraysContains(GenConstants.COLUMNTYPE_TEXT, dataType))
45 47 {
46   - column.setJavaType(GenConstants.TYPE_STRING);
47 48 // 字符串长度超过500设置为文本域
48 49 Integer columnLength = getColumnLength(column.getColumnType());
49   - String htmlType = columnLength >= 500 ? GenConstants.HTML_TEXTAREA : GenConstants.HTML_INPUT;
  50 + String htmlType = columnLength >= 500 || arraysContains(GenConstants.COLUMNTYPE_TEXT, dataType) ? GenConstants.HTML_TEXTAREA : GenConstants.HTML_INPUT;
50 51 column.setHtmlType(htmlType);
51 52 }
52 53 else if (arraysContains(GenConstants.COLUMNTYPE_TIME, dataType))
... ...