-- =============================================
-- 最终诊断 - 为什么菜单不显示
-- =============================================

-- 1. 检查parent_id是否正确
SELECT 
    m1.menu_id AS parent_menu_id,
    m1.menu_name AS parent_name,
    m2.menu_id AS child_menu_id,
    m2.menu_name AS child_name,
    m2.order_num
FROM sys_menu m1
LEFT JOIN sys_menu m2 ON m1.menu_id = m2.parent_id
WHERE m1.menu_name LIKE '%心理%' OR m1.menu_name LIKE '%测评%'
ORDER BY m1.menu_id, m2.order_num;

-- 2. 查看知识库管理的完整信息
SELECT 
    menu_id,
    menu_name,
    parent_id,
    order_num,
    path,
    component,
    is_frame,
    is_cache,
    menu_type,
    visible,
    status,
    perms,
    icon
FROM sys_menu 
WHERE menu_name = '知识库管理';

-- 3. 对比其他正常显示的菜单
SELECT 
    menu_id,
    menu_name,
    parent_id,
    order_num,
    menu_type,
    visible,
    status
FROM sys_menu 
WHERE parent_id = 2000
ORDER BY order_num;

-- 4. 检查菜单类型
-- C=目录 M=菜单 F=按钮
SELECT 
    menu_type,
    COUNT(*) as count,
    GROUP_CONCAT(menu_name) as menus
FROM sys_menu 
WHERE parent_id = 2000
GROUP BY menu_type;

-- 5. 如果parent_id=2000不对，查找正确的parent_id
SELECT menu_id, menu_name, parent_id, menu_type
FROM sys_menu 
WHERE menu_name LIKE '%心理%' OR menu_name LIKE '%测评%'
ORDER BY menu_id;
