Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
zhouwm808 committed Jun 1, 2022
1 parent 70f88ff commit f875b91
Showing 1 changed file with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -433,15 +433,21 @@ private List<Object> getModifyFieldList(List<SysMysqlColumns> 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() + ","
+ createTableParam.getFieldDecimalLength() + ")";
}

// 判断类型+长度是否相同

if (!sysColumn.getColumn_type().toLowerCase().equals(typeAndLength)) {
modifyFieldList.add(modifyTableParam);
continue;
Expand Down Expand Up @@ -659,6 +665,8 @@ private Field[] recursionParents(Class<?> clas, Field[] fields) {
if (clas.getSuperclass() != null) {
Class clsSup = clas.getSuperclass();
List<Field> fieldList = new ArrayList<Field>();
//把父类属性字段放到最前面
List<Field> superFieldList = new ArrayList<Field>();
fieldList.addAll(Arrays.asList(fields));
// 获取当前class的所有fields的name列表
List<String> fdNames = getFieldNames(fieldList);
Expand All @@ -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()) {
Expand Down

0 comments on commit f875b91

Please sign in to comment.