feat: apt 添加字段排序。

This commit is contained in:
Suomm 2023-07-07 21:19:31 +08:00
parent 2e802f3bf5
commit ab1da604d0
2 changed files with 10 additions and 2 deletions

View File

@ -149,7 +149,7 @@ public class MybatisFlexProcessor extends AbstractProcessor {
assert table != null;
// 类属性 fix: https://gitee.com/mybatis-flex/mybatis-flex/issues/I7I08X
Set<ColumnInfo> columnInfos = new HashSet<>();
Set<ColumnInfo> columnInfos = new TreeSet<>();
// 默认查询的属性 isLarge 字段
List<String> defaultColumns = new ArrayList<>();

View File

@ -24,7 +24,7 @@ import java.util.Objects;
* @author 王帅
* @since 2023-07-01
*/
public class ColumnInfo {
public class ColumnInfo implements Comparable<ColumnInfo> {
/**
* 属性名
@ -82,4 +82,12 @@ public class ColumnInfo {
return property != null ? property.hashCode() : 0;
}
@Override
public int compareTo(ColumnInfo o) {
// 先根据属性长度排序属性名短的在上
int compare = Integer.compare(property.length(), o.property.length());
// 属性名长度一样再按字母排序
return compare == 0 ? property.compareTo(o.property) : compare;
}
}