代码生成数据库文本类型生成表单文本域
This commit is contained in:
		
							parent
							
								
									0187344798
								
							
						
					
					
						commit
						63992ac906
					
				| 
						 | 
					@ -29,8 +29,10 @@ public class GenConstants
 | 
				
			||||||
    public static final String PARENT_MENU_NAME = "parentMenuName";
 | 
					    public static final String PARENT_MENU_NAME = "parentMenuName";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /** 数据库字符串类型 */
 | 
					    /** 数据库字符串类型 */
 | 
				
			||||||
    public static final String[] COLUMNTYPE_STR = { "char", "varchar", "nvarchar", "varchar2", "tinytext", "text",
 | 
					    public static final String[] COLUMNTYPE_STR = { "char", "varchar", "nvarchar", "varchar2" };
 | 
				
			||||||
            "mediumtext", "longtext" };
 | 
					
 | 
				
			||||||
 | 
					    /** 数据库文本类型 */
 | 
				
			||||||
 | 
					    public static final String[] COLUMNTYPE_TEXT = { "tinytext", "text", "mediumtext", "longtext" };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /** 数据库时间类型 */
 | 
					    /** 数据库时间类型 */
 | 
				
			||||||
    public static final String[] COLUMNTYPE_TIME = { "datetime", "time", "date", "timestamp" };
 | 
					    public static final String[] COLUMNTYPE_TIME = { "datetime", "time", "date", "timestamp" };
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -40,13 +40,14 @@ public class GenUtils
 | 
				
			||||||
        column.setCreateBy(table.getCreateBy());
 | 
					        column.setCreateBy(table.getCreateBy());
 | 
				
			||||||
        // 设置java字段名
 | 
					        // 设置java字段名
 | 
				
			||||||
        column.setJavaField(StringUtils.toCamelCase(columnName));
 | 
					        column.setJavaField(StringUtils.toCamelCase(columnName));
 | 
				
			||||||
 | 
					        // 设置默认类型
 | 
				
			||||||
        if (arraysContains(GenConstants.COLUMNTYPE_STR, dataType))
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
        column.setJavaType(GenConstants.TYPE_STRING);
 | 
					        column.setJavaType(GenConstants.TYPE_STRING);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (arraysContains(GenConstants.COLUMNTYPE_STR, dataType) || arraysContains(GenConstants.COLUMNTYPE_TEXT, dataType))
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
            // 字符串长度超过500设置为文本域
 | 
					            // 字符串长度超过500设置为文本域
 | 
				
			||||||
            Integer columnLength = getColumnLength(column.getColumnType());
 | 
					            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);
 | 
					            column.setHtmlType(htmlType);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        else if (arraysContains(GenConstants.COLUMNTYPE_TIME, dataType))
 | 
					        else if (arraysContains(GenConstants.COLUMNTYPE_TIME, dataType))
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue