-- 完整修复礼物菜单

-- 步骤1: 查看eb_system_menu表结构
DESC eb_system_menu;

-- 步骤2: 查看当前礼物相关菜单
SELECT * FROM eb_system_menu WHERE menu_name LIKE '%礼物%' OR path LIKE '%gift%';

-- 步骤3: 删除旧的礼物菜单
DELETE FROM eb_system_menu WHERE menu_name LIKE '%礼物%' OR path LIKE '%gift%';

-- 步骤4: 插入礼物打赏主菜单
INSERT INTO eb_system_menu (pid, menu_name, path, component, is_show, sort, icon, create_time, update_time) 
VALUES (0, '礼物打赏', '/gift', 'Layout', 1, 50, 'el-icon-present', NOW(), NOW());

-- 步骤5: 获取主菜单ID并插入子菜单
SET @gift_pid = (SELECT id FROM eb_system_menu WHERE path = '/gift' AND pid = 0);

INSERT INTO eb_system_menu (pid, menu_name, path, component, is_show, sort, icon, create_time, update_time) VALUES
(@gift_pid, '礼物列表', 'config', 'gift/config/index', 1, 1, 'el-icon-goods', NOW(), NOW()),
(@gift_pid, '打赏记录', 'records', 'gift/records/index', 1, 2, 'el-icon-document', NOW(), NOW()),
(@gift_pid, '充值套餐', 'recharge', 'gift/recharge/index', 1, 3, 'el-icon-coin', NOW(), NOW());

-- 步骤6: 验证结果
SELECT 
    CASE WHEN m.pid = 0 THEN '主菜单' ELSE '子菜单' END as '类型',
    m.id,
    m.pid,
    m.menu_name as '菜单名称',
    m.path as '路径',
    m.component as '组件',
    m.icon as '图标',
    m.sort as '排序',
    m.is_show as '显示'
FROM eb_system_menu m
WHERE m.path = '/gift' OR m.pid = @gift_pid
ORDER BY m.pid, m.sort;

-- 步骤7: 查看所有一级菜单（确认礼物打赏菜单的位置）
SELECT id, menu_name, path, icon, sort 
FROM eb_system_menu 
WHERE pid = 0 
ORDER BY sort;
