-- =====================================================
-- 在"社交互动"模块下添加"拉黑管理"菜单
-- =====================================================

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

-- 2. 查找现有的拉黑管理菜单（如果有的话）
SELECT id, pid, `name`, component FROM eb_system_menu WHERE `name` LIKE '%拉黑%';

-- 3. 添加"用户拉黑"菜单到社交互动下
-- 假设社交互动的ID需要查询，这里用变量方式
SET @social_pid = (SELECT id FROM eb_system_menu WHERE `name` = '社交互动' AND menu_type = 'M' LIMIT 1);

-- 如果社交互动菜单存在，添加拉黑子菜单
INSERT INTO eb_system_menu (`pid`, `name`, `icon`, `perms`, `component`, `menu_type`, `sort`, `is_show`, `is_delete`)
SELECT @social_pid, '用户拉黑', '', 'admin:blacklist:user', '/socialManage/blacklist/user', 'C', 100, 1, 0
FROM DUAL WHERE @social_pid IS NOT NULL
ON DUPLICATE KEY UPDATE `name` = '用户拉黑';

INSERT INTO eb_system_menu (`pid`, `name`, `icon`, `perms`, `component`, `menu_type`, `sort`, `is_show`, `is_delete`)
SELECT @social_pid, '房间拉黑', '', 'admin:blacklist:room', '/socialManage/blacklist/room', 'C', 101, 1, 0
FROM DUAL WHERE @social_pid IS NOT NULL
ON DUPLICATE KEY UPDATE `name` = '房间拉黑';

-- 4. 为管理员角色添加权限
INSERT IGNORE INTO eb_system_role_menu (rid, menu_id)
SELECT 1, id FROM eb_system_menu WHERE `name` IN ('用户拉黑', '房间拉黑') AND pid = @social_pid;

-- 5. 验证结果
SELECT '=== 社交互动下的菜单 ===' as info;
SELECT id, pid, `name`, component, sort 
FROM eb_system_menu 
WHERE pid = @social_pid
ORDER BY sort;
