diff --git a/src/main/java/com/yunhai/userbase/service/impl/GroupAuthzService.java b/src/main/java/com/yunhai/userbase/service/impl/GroupAuthzService.java index ac03bf6..ada0fd3 100644 --- a/src/main/java/com/yunhai/userbase/service/impl/GroupAuthzService.java +++ b/src/main/java/com/yunhai/userbase/service/impl/GroupAuthzService.java @@ -675,17 +675,49 @@ public class GroupAuthzService implements IGroupAuthzService { return bm; } + /** + * GetUserMod/oapi 模块列表排序:按 customId(配置编码,沿用旧系统 modId 语义)升序。
+ * 数字编码按数值比较("2" < "10"),非数字编码按字符串比较,解析并列时回退 id 升序。
+ * 不再使用 sortNo(空视为999沉底)+id 的重排——sortNo 基本未配置,会把后补建模块(id 较大) + * 擅自沉底,破坏配置编码顺序(如通知公告 1005 应用设置被 1006 通知统计反超)。 + */ private static Comparator moduleOrder() { return (a, b) -> { - int sa = a.getSortNo() == null ? 999 : a.getSortNo(); - int sb = b.getSortNo() == null ? 999 : b.getSortNo(); - if (sa != sb) { - return Integer.compare(sa, sb); + int c = compareCustomId(a.getCustomId(), b.getCustomId()); + if (c != 0) { + return c; } 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