From d0d5b3d82bf8b2a416a92dd817f22f4ec3fc2d64 Mon Sep 17 00:00:00 2001
From: “mitao” <“2763622819@qq.com”>
Date: 星期六, 14 二月 2026 20:24:22 +0800
Subject: [PATCH] feat(app):个人中心、消息通知接口

---
 xp-robotaxi-operation-boot/src/main/java/com/xiaopeng/operation/service/impl/SysMenuServiceImpl.java |   78 ++++++++++++++++++++++++++++++++++++++
 1 files changed, 77 insertions(+), 1 deletions(-)

diff --git a/xp-robotaxi-operation-boot/src/main/java/com/xiaopeng/operation/service/impl/SysMenuServiceImpl.java b/xp-robotaxi-operation-boot/src/main/java/com/xiaopeng/operation/service/impl/SysMenuServiceImpl.java
index 4501a89..38b26a9 100644
--- a/xp-robotaxi-operation-boot/src/main/java/com/xiaopeng/operation/service/impl/SysMenuServiceImpl.java
+++ b/xp-robotaxi-operation-boot/src/main/java/com/xiaopeng/operation/service/impl/SysMenuServiceImpl.java
@@ -1,9 +1,18 @@
 package com.xiaopeng.operation.service.impl;
 
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.xiaopeng.api.feignClient.account.SysGroupMenuClient;
+import com.xiaopeng.api.feignClient.account.SysRoleClient;
+import com.xiaopeng.api.feignClient.account.SysUserRoleClient;
+import com.xiaopeng.api.model.account.SysRole;
+import com.xiaopeng.api.model.account.SysUserRole;
 import com.xiaopeng.api.model.operation.SysMenu;
+import com.xiaopeng.common.core.domain.R;
+import com.xiaopeng.common.security.service.TokenService;
 import com.xiaopeng.operation.mapper.SysMenuMapper;
 import com.xiaopeng.operation.service.ISysMenuService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import java.util.*;
@@ -17,8 +26,21 @@
  * @author mitao
  * @since 2026-02-03
  */
+@Slf4j
 @Service
 public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> implements ISysMenuService {
+
+    @Autowired
+    private TokenService tokenService;
+
+    @Autowired
+    private SysUserRoleClient sysUserRoleClient;
+
+    @Autowired
+    private SysRoleClient sysRoleClient;
+
+    @Autowired
+    private SysGroupMenuClient sysGroupMenuClient;
 
     /**
      * 根据菜单ID列表查询菜单列表
@@ -105,7 +127,61 @@
 
     @Override
     public List<SysMenu> getPermission() {
+        try {
+            // 1. 获取当前登录用户ID
+            Long userId = tokenService.getLoginUser().getUserid();
+            if (userId == null) {
+                log.warn("获取当前登录用户ID失败");
+                return Collections.emptyList();
+            }
 
-        return Collections.emptyList();
+            // 2. 查询用户角色关联
+            R<SysUserRole> userRoleResult = sysUserRoleClient.selectSysUserRoleByUserId(userId);
+            if (userRoleResult == null || userRoleResult.getCode() != 200 || userRoleResult.getData() == null) {
+                log.warn("查询用户角色关联失败, userId={}", userId);
+                return Collections.emptyList();
+            }
+
+            Long roleId = userRoleResult.getData().getRoleId();
+            if (roleId == null) {
+                log.warn("用户未关联角色, userId={}", userId);
+                return Collections.emptyList();
+            }
+
+            // 3. 查询角色信息
+            R<SysRole> roleResult = sysRoleClient.getRoleById(roleId);
+            if (roleResult == null || roleResult.getCode() != 200 || roleResult.getData() == null) {
+                log.warn("查询角色信息失败, roleId={}", roleId);
+                return Collections.emptyList();
+            }
+
+            Long groupId = roleResult.getData().getGroupId();
+            if (groupId == null) {
+                log.warn("角色未关联权限组, roleId={}", roleId);
+                return Collections.emptyList();
+            }
+
+            // 4. 查询权限组关联的菜单ID列表
+            R<List<Long>> menuIdsResult = sysGroupMenuClient.selectMenuIdsByGroupId(groupId);
+            if (menuIdsResult == null || menuIdsResult.getCode() != 200 || menuIdsResult.getData() == null) {
+                log.warn("查询权限组菜单ID列表失败, groupId={}", groupId);
+                return Collections.emptyList();
+            }
+
+            List<Long> menuIds = menuIdsResult.getData();
+            if (menuIds.isEmpty()) {
+                log.info("权限组未关联菜单, groupId={}", groupId);
+                return Collections.emptyList();
+            }
+
+            // 5. 查询菜单详情
+            List<SysMenu> menus = this.listByIds(menuIds);
+            log.info("查询用户权限菜单成功, userId={}, menuCount={}", userId, menus.size());
+            return menus;
+
+        } catch (Exception e) {
+            log.error("查询用户权限菜单异常", e);
+            return Collections.emptyList();
+        }
     }
 }

--
Gitblit v1.7.1