-- =====================================================
-- 管理端侧边导航栏优化 - 完整菜单更新SQL
-- 
-- 使用说明：
-- 1. 先备份 eb_system_menu 表
-- 2. 执行此SQL
-- 3. 清除Redis缓存（删除key: menuList）
-- 4. 清除浏览器缓存并重新登录
-- =====================================================

-- 备份原表
CREATE TABLE IF NOT EXISTS eb_system_menu_backup_20251229 AS SELECT * FROM eb_system_menu;

-- =====================================================
-- 第一步：隐藏所有旧的一级菜单
-- =====================================================
UPDATE eb_system_menu SET is_show = 0 WHERE pid = 0;

-- =====================================================
-- 第二步：插入新的一级菜单（目录）
-- =====================================================

-- 1. 数据监控
INSERT INTO eb_system_menu (pid, name, icon, perms, component, menu_type, sort, is_show, is_delte, create_time, update_time)
VALUES (0, '数据监控', 'el-icon-monitor', 'admin:monitor', '/monitor', 'M', 100, 1, 0, NOW(), NOW());
SET @monitor_id = LAST_INSERT_ID();

-- 2. 用户管理
INSERT INTO eb_system_menu (pid, name, icon, perms, component, menu_type, sort, is_show, is_delte, create_time, update_time)
VALUES (0, '用户管理', 'el-icon-user', 'admin:user:manage', '/userManage', 'M', 99, 1, 0, NOW(), NOW());
SET @user_id = LAST_INSERT_ID();

-- 3. 直播管理
INSERT INTO eb_system_menu (pid, name, icon, perms, component, menu_type, sort, is_show, is_delte, create_time, update_time)
VALUES (0, '直播管理', 'el-icon-video-camera', 'admin:live:manage', '/liveManage', 'M', 98, 1, 0, NOW(), NOW());
SET @live_id = LAST_INSERT_ID();

-- 4. 社交互动
INSERT INTO eb_system_menu (pid, name, icon, perms, component, menu_type, sort, is_show, is_delte, create_time, update_time)
VALUES (0, '社交互动', 'el-icon-chat-dot-round', 'admin:social:manage', '/socialManage', 'M', 97, 1, 0, NOW(), NOW());
SET @social_id = LAST_INSERT_ID();

-- 5. 礼物打赏
INSERT INTO eb_system_menu (pid, name, icon, perms, component, menu_type, sort, is_show, is_delte, create_time, update_time)
VALUES (0, '礼物打赏', 'el-icon-present', 'admin:gift:manage', '/giftManage', 'M', 96, 1, 0, NOW(), NOW());
SET @gift_id = LAST_INSERT_ID();

-- 6. 虚拟道具
INSERT INTO eb_system_menu (pid, name, icon, perms, component, menu_type, sort, is_show, is_delte, create_time, update_time)
VALUES (0, '虚拟道具', 'el-icon-magic-stick', 'admin:virtual:manage', '/virtualProps', 'M', 95, 1, 0, NOW(), NOW());
SET @virtual_id = LAST_INSERT_ID();

-- 7. 营销活动
INSERT INTO eb_system_menu (pid, name, icon, perms, component, menu_type, sort, is_show, is_delte, create_time, update_time)
VALUES (0, '营销活动', 'el-icon-s-flag', 'admin:activity:manage', '/activityManage', 'M', 94, 1, 0, NOW(), NOW());
SET @activity_id = LAST_INSERT_ID();

-- 8. 任务系统
INSERT INTO eb_system_menu (pid, name, icon, perms, component, menu_type, sort, is_show, is_delte, create_time, update_time)
VALUES (0, '任务系统', 'el-icon-s-claim', 'admin:task:manage', '/taskManage', 'M', 93, 1, 0, NOW(), NOW());
SET @task_id = LAST_INSERT_ID();

-- 9. 财务管理
INSERT INTO eb_system_menu (pid, name, icon, perms, component, menu_type, sort, is_show, is_delte, create_time, update_time)
VALUES (0, '财务管理', 'el-icon-money', 'admin:finance:manage', '/financeManage', 'M', 92, 1, 0, NOW(), NOW());
SET @finance_id = LAST_INSERT_ID();

-- 10. 订单商城
INSERT INTO eb_system_menu (pid, name, icon, perms, component, menu_type, sort, is_show, is_delte, create_time, update_time)
VALUES (0, '订单商城', 'el-icon-shopping-cart-2', 'admin:shop:manage', '/shopManage', 'M', 91, 1, 0, NOW(), NOW());
SET @shop_id = LAST_INSERT_ID();

-- 11. 内容管理
INSERT INTO eb_system_menu (pid, name, icon, perms, component, menu_type, sort, is_show, is_delte, create_time, update_time)
VALUES (0, '内容管理', 'el-icon-document', 'admin:content:manage', '/contentManage', 'M', 90, 1, 0, NOW(), NOW());
SET @content_id = LAST_INSERT_ID();

-- 12. 用户反馈
INSERT INTO eb_system_menu (pid, name, icon, perms, component, menu_type, sort, is_show, is_delte, create_time, update_time)
VALUES (0, '用户反馈', 'el-icon-warning', 'admin:feedback:manage', '/feedbackManage', 'M', 89, 1, 0, NOW(), NOW());
SET @feedback_id = LAST_INSERT_ID();

-- 13. 代理管理
INSERT INTO eb_system_menu (pid, name, icon, perms, component, menu_type, sort, is_show, is_delte, create_time, update_time)
VALUES (0, '代理管理', 'el-icon-s-custom', 'admin:agent:manage', '/agentManage', 'M', 88, 1, 0, NOW(), NOW());
SET @agent_id = LAST_INSERT_ID();

-- 14. 系统设置
INSERT INTO eb_system_menu (pid, name, icon, perms, component, menu_type, sort, is_show, is_delte, create_time, update_time)
VALUES (0, '系统设置', 'el-icon-setting', 'admin:system:manage', '/systemSetting', 'M', 87, 1, 0, NOW(), NOW());
SET @system_id = LAST_INSERT_ID();

-- =====================================================
-- 第三步：插入二级菜单
-- =====================================================

-- 数据监控子菜单
INSERT INTO eb_system_menu (pid, name, icon, perms, component, menu_type, sort, is_show, is_delte, create_time, update_time) VALUES
(@monitor_id, '监控概览', '', 'admin:monitor:overview', '/monitor/overview', 'C', 100, 1, 0, NOW(), NOW()),
(@monitor_id, '在线用户', '', 'admin:monitor:users', '/monitor/users', 'C', 99, 1, 0, NOW(), NOW()),
(@monitor_id, '活跃房间', '', 'admin:monitor:rooms', '/monitor/rooms', 'C', 98, 1, 0, NOW(), NOW()),
(@monitor_id, '系统状态', '', 'admin:monitor:system', '/monitor/system', 'C', 97, 1, 0, NOW(), NOW());

-- 用户管理子菜单
INSERT INTO eb_system_menu (pid, name, icon, perms, component, menu_type, sort, is_show, is_delte, create_time, update_time) VALUES
(@user_id, '用户列表', '', 'admin:user:list', '/userManage/list', 'C', 100, 1, 0, NOW(), NOW()),
(@user_id, '私聊管理', '', 'admin:user:chat', '/userManage/chat', 'C', 99, 1, 0, NOW(), NOW()),
(@user_id, '用户等级', '', 'admin:user:grade', '/userManage/grade', 'C', 98, 1, 0, NOW(), NOW()),
(@user_id, '用户标签', '', 'admin:user:label', '/userManage/label', 'C', 97, 1, 0, NOW(), NOW()),
(@user_id, '会员包管理', '', 'admin:member:package', '/userManage/member/package', 'C', 96, 1, 0, NOW(), NOW()),
(@user_id, '贵族等级', '', 'admin:noble:list', '/userManage/noble/list', 'C', 95, 1, 0, NOW(), NOW()),
(@user_id, '魅力值等级', '', 'admin:charm:level', '/userManage/charm/level', 'C', 94, 1, 0, NOW(), NOW()),
(@user_id, '车辆认证', '', 'admin:auth:car', '/userManage/auth/car', 'C', 93, 1, 0, NOW(), NOW()),
(@user_id, '房间拉黑', '', 'admin:blacklist:room', '/userManage/blacklist/room', 'C', 92, 1, 0, NOW(), NOW()),
(@user_id, '用户拉黑', '', 'admin:blacklist:user', '/userManage/blacklist/user', 'C', 91, 1, 0, NOW(), NOW());

-- 直播管理子菜单
INSERT INTO eb_system_menu (pid, name, icon, perms, component, menu_type, sort, is_show, is_delte, create_time, update_time) VALUES
(@live_id, '房间列表', '', 'admin:room:list', '/liveManage/room/list', 'C', 100, 1, 0, NOW(), NOW()),
(@live_id, '房间类型', '', 'admin:room:type', '/liveManage/room/type', 'C', 99, 1, 0, NOW(), NOW()),
(@live_id, '房间背景', '', 'admin:room:background', '/liveManage/room/background', 'C', 98, 1, 0, NOW(), NOW()),
(@live_id, '家族列表', '', 'admin:family:list', '/liveManage/family/list', 'C', 97, 1, 0, NOW(), NOW()),
(@live_id, '家族级别', '', 'admin:family:level', '/liveManage/family/level', 'C', 96, 1, 0, NOW(), NOW()),
(@live_id, '家族成员', '', 'admin:family:member', '/liveManage/family/member', 'C', 95, 1, 0, NOW(), NOW()),
(@live_id, '粉丝团管理', '', 'admin:fangroup:list', '/liveManage/fanGroup/list', 'C', 94, 1, 0, NOW(), NOW());

-- 社交互动子菜单
INSERT INTO eb_system_menu (pid, name, icon, perms, component, menu_type, sort, is_show, is_delte, create_time, update_time) VALUES
(@social_id, '好友关系', '', 'admin:friend:list', '/socialManage/friend/list', 'C', 100, 1, 0, NOW(), NOW()),
(@social_id, '好友请求', '', 'admin:friend:requests', '/socialManage/friend/requests', 'C', 99, 1, 0, NOW(), NOW()),
(@social_id, '好友统计', '', 'admin:friend:statistics', '/socialManage/friend/statistics', 'C', 98, 1, 0, NOW(), NOW()),
(@social_id, '关注记录', '', 'admin:follow:record', '/socialManage/follow/record', 'C', 97, 1, 0, NOW(), NOW()),
(@social_id, '通话记录', '', 'admin:call:list', '/socialManage/call/list', 'C', 96, 1, 0, NOW(), NOW()),
(@social_id, '通话统计', '', 'admin:call:statistics', '/socialManage/call/statistics', 'C', 95, 1, 0, NOW(), NOW()),
(@social_id, '会话管理', '', 'admin:session:list', '/socialManage/session/list', 'C', 94, 1, 0, NOW(), NOW()),
(@social_id, '聊天常用语', '', 'admin:chatphrase:list', '/socialManage/chatPhrase/list', 'C', 93, 1, 0, NOW(), NOW()),
(@social_id, '动态评论', '', 'admin:comment:dynamic', '/socialManage/comment/dynamic', 'C', 92, 1, 0, NOW(), NOW()),
(@social_id, '评论回复', '', 'admin:comment:reply', '/socialManage/comment/reply', 'C', 91, 1, 0, NOW(), NOW()),
(@social_id, '动态列表', '', 'admin:dynamic:list', '/socialManage/dynamic/list', 'C', 90, 1, 0, NOW(), NOW()),
(@social_id, '互动列表', '', 'admin:interact:list', '/socialManage/interact/index', 'C', 89, 1, 0, NOW(), NOW());

-- 礼物打赏子菜单
INSERT INTO eb_system_menu (pid, name, icon, perms, component, menu_type, sort, is_show, is_delte, create_time, update_time) VALUES
(@gift_id, '礼物列表', '', 'admin:gift:list', '/giftManage/list', 'C', 100, 1, 0, NOW(), NOW()),
(@gift_id, '礼物数量', '', 'admin:giftnum:list', '/giftManage/num', 'C', 99, 1, 0, NOW(), NOW()),
(@gift_id, '打赏记录', '', 'admin:giftreward:record', '/giftManage/reward/record', 'C', 98, 1, 0, NOW(), NOW());

-- 虚拟道具子菜单
INSERT INTO eb_system_menu (pid, name, icon, perms, component, menu_type, sort, is_show, is_delte, create_time, update_time) VALUES
(@virtual_id, '坐骑列表', '', 'admin:mount:list', '/virtualProps/mount/list', 'C', 100, 1, 0, NOW(), NOW()),
(@virtual_id, '坐骑购买记录', '', 'admin:mount:order', '/virtualProps/mount/order', 'C', 99, 1, 0, NOW(), NOW()),
(@virtual_id, '头饰列表', '', 'admin:headwear:list', '/virtualProps/headwear/list', 'C', 98, 1, 0, NOW(), NOW());

-- 营销活动子菜单
INSERT INTO eb_system_menu (pid, name, icon, perms, component, menu_type, sort, is_show, is_delte, create_time, update_time) VALUES
(@activity_id, '平台活动', '', 'admin:activity:platform', '/activityManage/platform/list', 'C', 100, 1, 0, NOW(), NOW()),
(@activity_id, '抽奖奖品', '', 'admin:lottery:prize', '/activityManage/lottery/prize', 'C', 99, 1, 0, NOW(), NOW()),
(@activity_id, '抽奖概率', '', 'admin:lottery:probability', '/activityManage/lottery/probability', 'C', 98, 1, 0, NOW(), NOW()),
(@activity_id, '优惠券列表', '', 'admin:coupon:list', '/activityManage/coupon/list', 'C', 97, 1, 0, NOW(), NOW()),
(@activity_id, '领取记录', '', 'admin:coupon:record', '/activityManage/coupon/record', 'C', 96, 1, 0, NOW(), NOW()),
(@activity_id, '秒杀配置', '', 'admin:seckill:config', '/activityManage/seckill/config', 'C', 95, 1, 0, NOW(), NOW()),
(@activity_id, '积分配置', '', 'admin:integral:config', '/activityManage/integral/config', 'C', 94, 1, 0, NOW(), NOW()),
(@activity_id, '积分日志', '', 'admin:integral:log', '/activityManage/integral/log', 'C', 93, 1, 0, NOW(), NOW()),
(@activity_id, '邀请管理', '', 'admin:invite:list', '/activityManage/invite/list', 'C', 92, 1, 0, NOW(), NOW()),
(@activity_id, '夫妻相文案', '', 'admin:couple:matchtext', '/activityManage/couple/matchText', 'C', 91, 1, 0, NOW(), NOW());

-- 任务系统子菜单
INSERT INTO eb_system_menu (pid, name, icon, perms, component, menu_type, sort, is_show, is_delte, create_time, update_time) VALUES
(@task_id, '签到配置', '', 'admin:sign:config', '/taskManage/sign/config', 'C', 100, 1, 0, NOW(), NOW()),
(@task_id, '签到记录', '', 'admin:sign:list', '/taskManage/sign/list', 'C', 99, 1, 0, NOW(), NOW()),
(@task_id, '新手任务', '', 'admin:novice:list', '/taskManage/novice/list', 'C', 98, 1, 0, NOW(), NOW()),
(@task_id, '任务记录', '', 'admin:novice:usertask', '/taskManage/novice/userTask', 'C', 97, 1, 0, NOW(), NOW());

-- 财务管理子菜单
INSERT INTO eb_system_menu (pid, name, icon, perms, component, menu_type, sort, is_show, is_delte, create_time, update_time) VALUES
(@finance_id, '提现审核', '', 'admin:withdraw:index', '/financeManage/withdraw/index', 'C', 100, 1, 0, NOW(), NOW()),
(@finance_id, '提现金额配置', '', 'admin:withdraw:amount', '/financeManage/withdraw/amount', 'C', 99, 1, 0, NOW(), NOW()),
(@finance_id, '充值记录', '', 'admin:charge:record', '/financeManage/charge/record', 'C', 98, 1, 0, NOW(), NOW()),
(@finance_id, '资金监控', '', 'admin:fund:monitor', '/financeManage/monitor', 'C', 97, 1, 0, NOW(), NOW()),
(@finance_id, '兑换记录', '', 'admin:exchange:record', '/financeManage/exchange/record', 'C', 96, 1, 0, NOW(), NOW()),
(@finance_id, '金币明细', '', 'admin:detail:coin', '/financeManage/detail/coin', 'C', 95, 1, 0, NOW(), NOW()),
(@finance_id, '钻石明细', '', 'admin:detail:diamond', '/financeManage/detail/diamond', 'C', 94, 1, 0, NOW(), NOW()),
(@finance_id, '魅力值明细', '', 'admin:detail:charm', '/financeManage/detail/charm', 'C', 93, 1, 0, NOW(), NOW()),
(@finance_id, '金币钻石配置', '', 'admin:config:golddiamond', '/financeManage/config/goldDiamond', 'C', 92, 1, 0, NOW(), NOW()),
(@finance_id, '聊天付费配置', '', 'admin:config:chatpay', '/financeManage/config/chatPay', 'C', 91, 1, 0, NOW(), NOW()),
(@finance_id, '订单列表', '', 'admin:finance:order', '/financeManage/order/list', 'C', 90, 1, 0, NOW(), NOW()),
(@finance_id, '充值订单', '', 'admin:finance:recharge', '/financeManage/order/recharge', 'C', 89, 1, 0, NOW(), NOW());

-- 订单商城子菜单
INSERT INTO eb_system_menu (pid, name, icon, perms, component, menu_type, sort, is_show, is_delte, create_time, update_time) VALUES
(@shop_id, '商品管理', '', 'admin:store:index', '/shopManage/store/index', 'C', 100, 1, 0, NOW(), NOW()),
(@shop_id, '商品分类', '', 'admin:store:sort', '/shopManage/store/sort', 'C', 99, 1, 0, NOW(), NOW()),
(@shop_id, '商品规格', '', 'admin:store:attr', '/shopManage/store/attr', 'C', 98, 1, 0, NOW(), NOW()),
(@shop_id, '商品评论', '', 'admin:store:comment', '/shopManage/store/comment', 'C', 97, 1, 0, NOW(), NOW()),
(@shop_id, '订单管理', '', 'admin:order:index', '/shopManage/order/index', 'C', 96, 1, 0, NOW(), NOW()),
(@shop_id, '分销员管理', '', 'admin:distribution:index', '/shopManage/distribution/index', 'C', 95, 1, 0, NOW(), NOW()),
(@shop_id, '分销配置', '', 'admin:distribution:config', '/shopManage/distribution/config', 'C', 94, 1, 0, NOW(), NOW());

-- 内容管理子菜单
INSERT INTO eb_system_menu (pid, name, icon, perms, component, menu_type, sort, is_show, is_delte, create_time, update_time) VALUES
(@content_id, '文章管理', '', 'admin:article:list', '/contentManage/article/list', 'C', 100, 1, 0, NOW(), NOW()),
(@content_id, '文章分类', '', 'admin:article:category', '/contentManage/article/category', 'C', 99, 1, 0, NOW(), NOW()),
(@content_id, '轮播图管理', '', 'admin:banner:list', '/contentManage/banner/list', 'C', 98, 1, 0, NOW(), NOW()),
(@content_id, '系统消息', '', 'admin:message:list', '/contentManage/message/list', 'C', 97, 1, 0, NOW(), NOW()),
(@content_id, '客服联系方式', '', 'admin:help:customerservice', '/contentManage/help/customerService', 'C', 96, 1, 0, NOW(), NOW());

-- 用户反馈子菜单
INSERT INTO eb_system_menu (pid, name, icon, perms, component, menu_type, sort, is_show, is_delte, create_time, update_time) VALUES
(@feedback_id, '举报列表', '', 'admin:report:list', '/feedbackManage/report/list', 'C', 100, 1, 0, NOW(), NOW()),
(@feedback_id, '反馈列表', '', 'admin:feedback:list', '/feedbackManage/feedback/list', 'C', 99, 1, 0, NOW(), NOW()),
(@feedback_id, '申诉管理', '', 'admin:appeal:list', '/feedbackManage/appeal/list', 'C', 98, 1, 0, NOW(), NOW());

-- 代理管理子菜单
INSERT INTO eb_system_menu (pid, name, icon, perms, component, menu_type, sort, is_show, is_delte, create_time, update_time) VALUES
(@agent_id, '代理列表', '', 'admin:agent:list', '/agentManage/list', 'C', 100, 1, 0, NOW(), NOW()),
(@agent_id, '提现申请', '', 'admin:agent:withdraw', '/agentManage/withdraw', 'C', 99, 1, 0, NOW(), NOW()),
(@agent_id, '消息记录', '', 'admin:agent:message', '/agentManage/message', 'C', 98, 1, 0, NOW(), NOW()),
(@agent_id, '社会动态', '', 'admin:social:dynamic', '/agentManage/social/dynamic', 'C', 97, 1, 0, NOW(), NOW());

-- 系统设置子菜单
INSERT INTO eb_system_menu (pid, name, icon, perms, component, menu_type, sort, is_show, is_delte, create_time, update_time) VALUES
(@system_id, '系统设置', '', 'admin:setting:basic', '/systemSetting/basic', 'C', 100, 1, 0, NOW(), NOW()),
(@system_id, '消息通知', '', 'admin:setting:notification', '/systemSetting/notification', 'C', 99, 1, 0, NOW(), NOW()),
(@system_id, '角色管理', '', 'admin:role:identity', '/systemSetting/role/identity', 'C', 98, 1, 0, NOW(), NOW()),
(@system_id, '管理员列表', '', 'admin:role:admin', '/systemSetting/role/admin', 'C', 97, 1, 0, NOW(), NOW()),
(@system_id, '权限规则', '', 'admin:role:permission', '/systemSetting/role/permission', 'C', 96, 1, 0, NOW(), NOW()),
(@system_id, '一键换色', '', 'admin:design:theme', '/systemSetting/design/theme', 'C', 95, 1, 0, NOW(), NOW()),
(@system_id, '页面设计', '', 'admin:design:page', '/systemSetting/design/page', 'C', 94, 1, 0, NOW(), NOW()),
(@system_id, '首页装修', '', 'admin:design:home', '/systemSetting/design/home', 'C', 93, 1, 0, NOW(), NOW()),
(@system_id, '版本管理', '', 'admin:version:list', '/systemSetting/version/list', 'C', 92, 1, 0, NOW(), NOW()),
(@system_id, '敏感词管理', '', 'admin:sensitiveword:list', '/systemSetting/sensitiveWord/list', 'C', 91, 1, 0, NOW(), NOW()),
(@system_id, '验证码管理', '', 'admin:verifycode:list', '/systemSetting/verifycode/list', 'C', 90, 1, 0, NOW(), NOW()),
(@system_id, '参数配置', '', 'admin:config:params', '/systemSetting/config/params', 'C', 89, 1, 0, NOW(), NOW()),
(@system_id, '配置分类', '', 'admin:dev:category', '/systemSetting/dev/category', 'C', 88, 1, 0, NOW(), NOW()),
(@system_id, '组合数据', '', 'admin:dev:combineddata', '/systemSetting/dev/combinedData', 'C', 87, 1, 0, NOW(), NOW()),
(@system_id, '素材管理', '', 'admin:picture:manage', '/systemSetting/picture', 'C', 86, 1, 0, NOW(), NOW()),
(@system_id, '缓存清除', '', 'admin:cache:clear', '/systemSetting/clearCache', 'C', 85, 1, 0, NOW(), NOW()),
(@system_id, '定时任务', '', 'admin:schedule:list', '/systemSetting/schedule/list', 'C', 84, 1, 0, NOW(), NOW()),
(@system_id, '任务日志', '', 'admin:schedule:log', '/systemSetting/schedule/log', 'C', 83, 1, 0, NOW(), NOW());

-- =====================================================
-- 完成提示
-- =====================================================
SELECT '菜单优化完成！请执行以下操作：' AS message
UNION ALL
SELECT '1. 清除Redis缓存（删除key: menuList）'
UNION ALL
SELECT '2. 清除浏览器缓存（Ctrl+Shift+Delete）'
UNION ALL
SELECT '3. 重新登录管理后台'
UNION ALL
SELECT '4. 如需恢复，执行: UPDATE eb_system_menu SET is_show = 1 WHERE pid = 0';
