-- =====================================================
-- 在"社交互动"模块下添加"拉黑管理"菜单 (修正版)
-- =====================================================

-- 1. 查看菜单表结构
DESC eb_system_menu;

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

-- 3. 获取社交互动的ID
SET @social_pid = (SELECT id FROM eb_system_menu WHERE `name` = '社交互动' AND menu_type = 'M' LIMIT 1);
SELECT @social_pid as social_menu_id;

-- 4. 添加"用户拉黑"菜单
INSERT INTO eb_system_menu (`pid`, `name`, `icon`, `perms`, `component`, `menu_type`, `sort`, `is_show`)
VALUES (@social_pid, '用户拉黑', '', 'admin:blacklist:user', '/socialManage/blacklist/user', 'C', 100, 1)
ON DUPLICATE KEY UPDATE `component` = '/socialManage/blacklist/user';

-- 5. 添加"房间拉黑"菜单
INSERT INTO eb_system_menu (`pid`, `name`, `icon`, `perms`, `component`, `menu_type`, `sort`, `is_show`)
VALUES (@social_pid, '房间拉黑', '', 'admin:blacklist:room', '/socialManage/blacklist/room', 'C', 101, 1)
ON DUPLICATE KEY UPDATE `component` = '/socialManage/blacklist/room';

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

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