-- ========================================
-- 诊断直播管理菜单404问题
-- ========================================

-- 1. 查找所有直播相关的菜单
SELECT 
    id,
    pid,
    name,
    component,
    is_show,
    sort,
    CASE 
        WHEN is_show = 1 THEN '显示'
        ELSE '隐藏'
    END as display_status
FROM eb_system_menu 
WHERE name LIKE '%直播%' 
   OR component LIKE '%live%'
   OR component LIKE '%room%'
   OR component LIKE '%family%'
   OR component LIKE '%fanGroup%'
   OR component LIKE '%streamer%'
ORDER BY pid, sort, id;

-- 2. 查找礼物相关的菜单
SELECT 
    id,
    pid,
    name,
    component,
    is_show,
    sort
FROM eb_system_menu 
WHERE name LIKE '%礼物%' 
   OR component LIKE '%gift%'
ORDER BY pid, sort, id;

-- 3. 检查是否有component路径冲突
SELECT 
    component,
    COUNT(*) as count,
    GROUP_CONCAT(CONCAT(id, ':', name) SEPARATOR ' | ') as conflicting_menus
FROM eb_system_menu 
WHERE is_show = 1
  AND component IS NOT NULL
  AND component != ''
GROUP BY component
HAVING count > 1;

-- ========================================
-- 修复方案：确保component字段与前端路由path匹配
-- ========================================

-- 前端路由配置：
-- liveManageRouter.path = '/liveManage'
-- 子路由：
--   - 'room/list' -> '/liveManage/room/list'
--   - 'family/list' -> '/liveManage/family/list'
--   - 'family/level' -> '/liveManage/family/level'
--   - 'family/member' -> '/liveManage/family/member'
--   - 'fanGroup/list' -> '/liveManage/fanGroup/list'
--   - 'streamer/list' -> '/liveManage/streamer/list'

-- 礼物路由配置：
-- giftManageRouter.path = '/gift'
-- 子路由：
--   - 'records/index' -> '/gift/records/index'

-- 4. 查看当前直播管理菜单的component配置
SELECT 
    id,
    pid,
    name,
    component,
    '应该是: /liveManage' as expected_component
FROM eb_system_menu 
WHERE name = '直播管理'
LIMIT 1;

-- 5. 查看直播管理的子菜单
SELECT 
    id,
    pid,
    name,
    component,
    CASE 
        WHEN name LIKE '%房间%' THEN '应该是: /liveManage/room/list'
        WHEN name LIKE '%家族列表%' THEN '应该是: /liveManage/family/list'
        WHEN name LIKE '%家族级别%' THEN '应该是: /liveManage/family/level'
        WHEN name LIKE '%家族成员%' THEN '应该是: /liveManage/family/member'
        WHEN name LIKE '%粉丝团%' THEN '应该是: /liveManage/fanGroup/list'
        WHEN name LIKE '%主播%' THEN '应该是: /liveManage/streamer/list'
        ELSE '未知'
    END as expected_component
FROM eb_system_menu 
WHERE pid IN (SELECT id FROM eb_system_menu WHERE name = '直播管理')
ORDER BY sort;
