作者 RuoYi

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

@@ -29,8 +29,10 @@ public class GenConstants @@ -29,8 +29,10 @@ public class GenConstants
29 public static final String PARENT_MENU_NAME = "parentMenuName"; 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 public static final String[] COLUMNTYPE_TIME = { "datetime", "time", "date", "timestamp" }; 38 public static final String[] COLUMNTYPE_TIME = { "datetime", "time", "date", "timestamp" };
@@ -40,13 +40,14 @@ public class GenUtils @@ -40,13 +40,14 @@ public class GenUtils
40 column.setCreateBy(table.getCreateBy()); 40 column.setCreateBy(table.getCreateBy());
41 // 设置java字段名 41 // 设置java字段名
42 column.setJavaField(StringUtils.toCamelCase(columnName)); 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 // 字符串长度超过500设置为文本域 48 // 字符串长度超过500设置为文本域
48 Integer columnLength = getColumnLength(column.getColumnType()); 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 column.setHtmlType(htmlType); 51 column.setHtmlType(htmlType);
51 } 52 }
52 else if (arraysContains(GenConstants.COLUMNTYPE_TIME, dataType)) 53 else if (arraysContains(GenConstants.COLUMNTYPE_TIME, dataType))