From f875b91da8df7104358fd84aae00d3a5afd16781 Mon Sep 17 00:00:00 2001 From: zhouwm2008 Date: Wed, 1 Jun 2022 15:21:11 +0800 Subject: [PATCH] fix #19 #20 --- .../system/SysMysqlCreateTableManagerImpl.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/mybatis-enhance-actable/src/main/java/com/gitee/sunchenbin/mybatis/actable/manager/system/SysMysqlCreateTableManagerImpl.java b/mybatis-enhance-actable/src/main/java/com/gitee/sunchenbin/mybatis/actable/manager/system/SysMysqlCreateTableManagerImpl.java index 6ec8506..294af5e 100644 --- a/mybatis-enhance-actable/src/main/java/com/gitee/sunchenbin/mybatis/actable/manager/system/SysMysqlCreateTableManagerImpl.java +++ b/mybatis-enhance-actable/src/main/java/com/gitee/sunchenbin/mybatis/actable/manager/system/SysMysqlCreateTableManagerImpl.java @@ -433,8 +433,13 @@ private List getModifyFieldList(List tableColumnList, L // 3.验证长度个小数点位数 String typeAndLength = createTableParam.getFieldType().toLowerCase(); if (createTableParam.getFileTypeLength() == 1) { - // 拼接出类型加长度,比如varchar(1) - typeAndLength = typeAndLength + "(" + createTableParam.getFieldLength() + ")"; + //如果是int类型,mysql5.6及以下版本为int(11),mysql5.7及以上版本为int,此处兼容处理 + if("int".equalsIgnoreCase(typeAndLength) && "int".equalsIgnoreCase(sysColumn.getColumn_type())) { + //只有类型,不需要拼接长度,mysql5.7后int型不能设置长度 + } else { + // 拼接出类型加长度,比如varchar(1) + typeAndLength = typeAndLength + "(" + createTableParam.getFieldLength() + ")"; + } } else if (createTableParam.getFileTypeLength() == 2) { // 拼接出类型加长度,比如varchar(1) typeAndLength = typeAndLength + "(" + createTableParam.getFieldLength() + "," @@ -442,6 +447,7 @@ private List getModifyFieldList(List tableColumnList, L } // 判断类型+长度是否相同 + if (!sysColumn.getColumn_type().toLowerCase().equals(typeAndLength)) { modifyFieldList.add(modifyTableParam); continue; @@ -659,6 +665,8 @@ private Field[] recursionParents(Class clas, Field[] fields) { if (clas.getSuperclass() != null) { Class clsSup = clas.getSuperclass(); List fieldList = new ArrayList(); + //把父类属性字段放到最前面 + List superFieldList = new ArrayList(); fieldList.addAll(Arrays.asList(fields)); // 获取当前class的所有fields的name列表 List fdNames = getFieldNames(fieldList); @@ -669,6 +677,7 @@ private Field[] recursionParents(Class clas, Field[] fields) { } fieldList.add(pfd); } + fieldList.addAll(0, superFieldList); fields = new Field[fieldList.size()]; int i = 0; for (Object field : fieldList.toArray()) {