-- 诊断用户管理菜单问题
USE soybean_admin;

SELECT '========================================' AS '';
SELECT '检查用户管理相关路由' AS '';
SELECT '========================================' AS '';
SELECT route_id, name, path, component, status, order_num
FROM sys_route 
WHERE route_id LIKE 'user%' OR name LIKE 'user%'
ORDER BY order_num;

SELECT '' AS '';
SELECT '========================================' AS '';
SELECT '检查 R_SUPER 角色的菜单配置' AS '';
SELECT '========================================' AS '';
SELECT role_code, role_name, menus
FROM sys_role 
WHERE role_code = 'R_SUPER';

SELECT '' AS '';
SELECT '========================================' AS '';
SELECT '检查子路由是否在角色配置中' AS '';
SELECT '========================================' AS '';
SELECT 
    r.route_id,
    r.name AS route_name,
    r.path,
    CASE 
        WHEN role.menus LIKE CONCAT('%', r.name, '%') THEN '✓ 在配置中'
        ELSE '✗ 不在配置中 - 会被过滤！'
    END AS in_role_config
FROM sys_route r
CROSS JOIN sys_role role
WHERE role.role_code = 'R_SUPER'
  AND (r.route_id LIKE 'user%' OR r.name LIKE 'user%')
ORDER BY r.order_num;
