GetUserMod模块列表改按customId配置编码排序
This commit is contained in:
@@ -675,17 +675,49 @@ public class GroupAuthzService implements IGroupAuthzService {
|
|||||||
return bm;
|
return bm;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GetUserMod/oapi 模块列表排序:按 customId(配置编码,沿用旧系统 modId 语义)升序。<br>
|
||||||
|
* 数字编码按数值比较("2" < "10"),非数字编码按字符串比较,解析并列时回退 id 升序。<br>
|
||||||
|
* 不再使用 sortNo(空视为999沉底)+id 的重排——sortNo 基本未配置,会把后补建模块(id 较大)
|
||||||
|
* 擅自沉底,破坏配置编码顺序(如通知公告 1005 应用设置被 1006 通知统计反超)。
|
||||||
|
*/
|
||||||
private static Comparator<AppModule> moduleOrder() {
|
private static Comparator<AppModule> moduleOrder() {
|
||||||
return (a, b) -> {
|
return (a, b) -> {
|
||||||
int sa = a.getSortNo() == null ? 999 : a.getSortNo();
|
int c = compareCustomId(a.getCustomId(), b.getCustomId());
|
||||||
int sb = b.getSortNo() == null ? 999 : b.getSortNo();
|
if (c != 0) {
|
||||||
if (sa != sb) {
|
return c;
|
||||||
return Integer.compare(sa, sb);
|
|
||||||
}
|
}
|
||||||
return Integer.compare(a.getId() == null ? 0 : a.getId(), b.getId() == null ? 0 : b.getId());
|
return Integer.compare(a.getId() == null ? 0 : a.getId(), b.getId() == null ? 0 : b.getId());
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** customId 比较:null 排最后;双方均可解析为数字时按数值比较,否则按字符串比较。 */
|
||||||
|
private static int compareCustomId(String x, String y) {
|
||||||
|
if (x == null && y == null) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if (x == null) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if (y == null) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
Long nx = parseLongOrNull(x.trim());
|
||||||
|
Long ny = parseLongOrNull(y.trim());
|
||||||
|
if (nx != null && ny != null) {
|
||||||
|
return Long.compare(nx, ny);
|
||||||
|
}
|
||||||
|
return x.compareTo(y);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Long parseLongOrNull(String s) {
|
||||||
|
try {
|
||||||
|
return Long.parseLong(s);
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ===================== 权限一览 =====================
|
// ===================== 权限一览 =====================
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user