| | |
| | | genTable.setBusinessName(getBusinessName(genTable.getTableName())); |
| | | genTable.setFunctionName(replaceText(genTable.getTableComment())); |
| | | genTable.setFunctionAuthor(GenConfig.getAuthor()); |
| | | genTable.setCreateTime(null); |
| | | genTable.setUpdateTime(null); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | public static void initColumnField(GenTableColumn column, GenTable table) { |
| | | String dataType = getDbType(column.getColumnType()); |
| | | String columnName = column.getColumnName(); |
| | | // 统一转小写 避免有些数据库默认大写问题 如果需要特别书写方式 请在实体类增加注解标注别名 |
| | | String columnName = column.getColumnName().toLowerCase(); |
| | | column.setTableId(table.getTableId()); |
| | | column.setCreateBy(table.getCreateBy()); |
| | | column.setCreateTime(null); |
| | | column.setUpdateTime(null); |
| | | // 设置java字段名 |
| | | column.setJavaField(StringUtils.toCamelCase(columnName)); |
| | | // 设置默认类型 |
| | |
| | | column.setHtmlType(GenConstants.HTML_DATETIME); |
| | | } else if (arraysContains(GenConstants.COLUMNTYPE_NUMBER, dataType)) { |
| | | column.setHtmlType(GenConstants.HTML_INPUT); |
| | | |
| | | // 如果是浮点型 统一用BigDecimal |
| | | String[] str = StringUtils.split(StringUtils.substringBetween(column.getColumnType(), "(", ")"), StringUtils.SEPARATOR); |
| | | if (str != null && str.length == 2 && Integer.parseInt(str[1]) > 0) { |
| | | column.setJavaType(GenConstants.TYPE_BIGDECIMAL); |
| | | } |
| | | // 如果是整形 |
| | | else if (str != null && str.length == 1 && Integer.parseInt(str[0]) <= 10) { |
| | | column.setJavaType(GenConstants.TYPE_INTEGER); |
| | | } |
| | | // 长整形 |
| | | else { |
| | | column.setJavaType(GenConstants.TYPE_LONG); |
| | | } |
| | | // 数据库的数字字段与java不匹配 且很多数据库的数字字段很模糊 例如oracle只有number没有细分 |
| | | // 所以默认数字类型全为Long可在界面上自行编辑想要的类型 有什么特殊需求也可以在这里特殊处理 |
| | | column.setJavaType(GenConstants.TYPE_LONG); |
| | | } |
| | | |
| | | // BO对象 默认插入勾选 |
| | |
| | | // BO对象 默认编辑勾选 |
| | | if (!arraysContains(GenConstants.COLUMNNAME_NOT_EDIT, columnName)) { |
| | | column.setIsEdit(GenConstants.REQUIRE); |
| | | } |
| | | // BO对象 默认是否必填勾选 |
| | | if (!arraysContains(GenConstants.COLUMNNAME_NOT_EDIT, columnName)) { |
| | | column.setIsRequired(GenConstants.REQUIRE); |
| | | } |
| | | // VO对象 默认返回勾选 |
| | | if (!arraysContains(GenConstants.COLUMNNAME_NOT_LIST, columnName)) { |