-- =====================================================
-- 立即添加拉黑管理菜单到社交互动模块
-- =====================================================

-- 1. 先查看社交互动菜单的ID
SELECT id, pid, `name`, component, menu_type FROM eb_system_menu WHERE `name` = '社交互动';

-- 2. 查看现有的社交互动子菜单
SELECT id, pid, `name`, component, sort FROM eb_system_menu WHERE pid = (SELECT id FROM eb_system_menu WHERE `name` = '社交互动' LIMIT 1) ORDER BY sort;

-- 3. 检查是否已存在拉黑菜单
SELECT id, `name`, component FROM eb_system_menu WHERE `name` IN ('用户拉黑', '房间拉黑');

-- 4. 删除可能存在的旧记录（避免重复）
DELETE FROM eb_system_menu WHERE `name` = '用户拉黑' AND component LIKE '%blacklist%';
DELETE FROM eb_system_menu WHERE `name` = '房间拉黑' AND component LIKE '%blacklist%';

-- 5. 插入用户拉黑菜单（假设社交互动ID为某个值，需要先查询）
-- 先获取社交互动的ID
SET @social_id = (SELECT id FROM eb_system_menu WHERE `name` = '社交互动' AND menu_type = 'M' LIMIT 1);
SELECT @social_id as '社交互动菜单ID';

-- 6. 插入用户拉黑
INSERT INTO eb_system_menu (`pid`, `name`, `icon`, `perms`, `component`, `menu_type`, `sort`, `is_show`)
VALUES (@social_id, '用户拉黑', 'el-icon-user', 'admin:blacklist:user', '/socialManage/blacklist/user', 'C', 100, 1);

-- 7. 插入房间拉黑
INSERT INTO eb_system_menu (`pid`, `name`, `icon`, `perms`, `component`, `menu_type`, `sort`, `is_show`)
VALUES (@social_id, '房间拉黑', 'el-icon-house', 'admin:blacklist:room', '/socialManage/blacklist/room', 'C', 101, 1);

-- 8. 为管理员角色(rid=1)添加权限
INSERT IGNORE INTO eb_system_role_menu (rid, menu_id)
SELECT 1, id FROM eb_system_menu WHERE `name` = '用户拉黑' AND component = '/socialManage/blacklist/user';

INSERT IGNORE INTO eb_system_role_menu (rid, menu_id)
SELECT 1, id FROM eb_system_menu WHERE `name` = '房间拉黑' AND component = '/socialManage/blacklist/room';

-- 9. 验证插入结果
SELECT '=== 新增的拉黑菜单 ===' as info;
SELECT id, pid, `name`, component, sort, is_show 
FROM eb_system_menu 
WHERE `name` IN ('用户拉黑', '房间拉黑')
ORDER BY id DESC;

-- 10. 验证社交互动下所有子菜单
SELECT '=== 社交互动下所有子菜单 ===' as info;
SELECT id, `name`, component, sort, is_show 
FROM eb_system_menu 
WHERE pid = @social_id
ORDER BY sort;
