From 917e0939866e6198f1b39b062babdfbf3bbb94d4 Mon Sep 17 00:00:00 2001
From: xuhy <3313886187@qq.com>
Date: 星期四, 26 二月 2026 11:09:38 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 xp-robotaxi-account-boot/src/main/java/com/xiaopeng/account/service/impl/SysPermissionServiceImpl.java |   77 +++++++++++++++++++++-----------------
 1 files changed, 42 insertions(+), 35 deletions(-)

diff --git a/xp-robotaxi-account-boot/src/main/java/com/xiaopeng/account/service/impl/SysPermissionServiceImpl.java b/xp-robotaxi-account-boot/src/main/java/com/xiaopeng/account/service/impl/SysPermissionServiceImpl.java
index 4cceb78..1c8651d 100644
--- a/xp-robotaxi-account-boot/src/main/java/com/xiaopeng/account/service/impl/SysPermissionServiceImpl.java
+++ b/xp-robotaxi-account-boot/src/main/java/com/xiaopeng/account/service/impl/SysPermissionServiceImpl.java
@@ -4,6 +4,7 @@
 import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
+import java.util.stream.Collectors;
 
 import com.xiaopeng.account.service.ISysGroupMenuService;
 import com.xiaopeng.account.service.ISysPermissionService;
@@ -73,45 +74,51 @@
      * @return 菜单权限信息
      */
     @Override
-    public List<SysMenu> getMenuPermission(SysUser user)
+    public Set<String> getMenuPermission(SysUser user)
     {
-        List<SysMenu> menus = new ArrayList<>();
+        Set<String> perms = new HashSet<>();
+        // 管理员拥有所有权限
+        if (user.isAdmin()) {
+            perms.add("*:*:*");
+        } else {
+            try {
+                // 1. 根据 userId 查询 sys_user_role 获取 roleId
+                SysUserRole userRole = userRoleService.selectSysUserRoleByUserId(user.getId());
+                if (userRole == null || userRole.getRoleId() == null) {
+                    log.warn("用户[{}]未分配角色", user.getId());
+                    return perms;
+                }
+                Long roleId = userRole.getRoleId();
 
-        try {
-            // 1. 根据 userId 查询 sys_user_role 获取 roleId
-            SysUserRole userRole = userRoleService.selectSysUserRoleByUserId(user.getId());
-            if (userRole == null || userRole.getRoleId() == null) {
-                log.warn("用户[{}]未分配角色", user.getId());
-                return menus;
+                // 2. 根据 roleId 查询 sys_role 获取 groupId
+                Long groupId = roleService.selectGroupIdByRoleId(roleId);
+                if (groupId == null) {
+                    log.warn("角色[{}]未关联权限组", roleId);
+                    return perms;
+                }
+
+                // 3. 根据 groupId 查询 sys_group_menu 获取 menuId 列表
+                List<Long> menuIds = groupMenuService.selectMenuIdsByGroupId(groupId);
+                if (menuIds == null || menuIds.isEmpty()) {
+                    log.warn("权限组[{}]未配置菜单权限", groupId);
+                    return perms;
+                }
+
+                // 4. 通过 Feign 调用 operation 服务,根据 menuId 列表获取菜单列表
+                R<List<SysMenu>> result = sysMenuClient.getMenusByMenuIds(menuIds);
+                if (R.isSuccess(result) && result.getData() != null) {
+                    perms = result.getData().stream().map(item -> item.getId().toString()).collect(Collectors.toSet());
+                } else {
+                    log.error("调用菜单服务获取菜单列表失败: {}", result != null ? result.getMsg() : "返回结果为空");
+                }
+
+            } catch (Exception e) {
+                log.error("获取用户[{}]菜单权限异常", user.getId(), e);
             }
-            Long roleId = userRole.getRoleId();
-
-            // 2. 根据 roleId 查询 sys_role 获取 groupId
-            Long groupId = roleService.selectGroupIdByRoleId(roleId);
-            if (groupId == null) {
-                log.warn("角色[{}]未关联权限组", roleId);
-                return menus;
-            }
-
-            // 3. 根据 groupId 查询 sys_group_menu 获取 menuId 列表
-            List<Long> menuIds = groupMenuService.selectMenuIdsByGroupId(groupId);
-            if (menuIds == null || menuIds.isEmpty()) {
-                log.warn("权限组[{}]未配置菜单权限", groupId);
-                return menus;
-            }
-
-            // 4. 通过 Feign 调用 operation 服务,根据 menuId 列表获取菜单列表
-            R<List<SysMenu>> result = sysMenuClient.getMenusByMenuIds(menuIds);
-            if (R.isSuccess(result) && result.getData() != null) {
-                menus = result.getData();
-            } else {
-                log.error("调用菜单服务获取菜单列表失败: {}", result != null ? result.getMsg() : "返回结果为空");
-            }
-
-        } catch (Exception e) {
-            log.error("获取用户[{}]菜单权限异常", user.getId(), e);
         }
 
-        return menus;
+
+
+        return perms;
     }
 }

--
Gitblit v1.7.1