-- =====================================================
-- adminUI 总后台菜单初始化 SQL (sys_menu，非 fs_menu)
-- 将前端硬编码菜单迁移到数据库，支持角色-菜单权限分配
-- =====================================================

-- 1. 清理旧数据（谨慎执行，确保备份）
DELETE FROM sys_role_menu WHERE menu_id IN (
    SELECT menu_id FROM (SELECT menu_id FROM sys_menu WHERE menu_id >= 2000) t
);
DELETE FROM sys_menu WHERE menu_id >= 2000;

-- 2. 根节点：/admin
INSERT INTO sys_menu (menu_id, menu_name, parent_id, order_num, path, component, menu_type, icon, visible, status, is_frame, is_cache, create_by, create_time, remark)
VALUES (2000, '总后台', 0, 1, 'admin', 'AdminLayout', 'M', 'el-icon-s-platform', '0', '0', 0, 0, 'admin', NOW(), 'adminUI根路由');

-- 3. 数据看板（作为 /admin 的默认重定向页面）
INSERT INTO sys_menu (menu_id, menu_name, parent_id, order_num, path, component, menu_type, icon, visible, status, is_frame, is_cache, create_by, create_time, remark)
VALUES (2001, '数据看板', 2000, 0, 'dashboard', 'admin/dashboard/index', 'C', 'el-icon-s-data', '0', '0', 0, 0, 'admin', NOW(), '默认首页');

-- ============================================================================
-- 4. 分组 1：租户代理
-- ============================================================================
INSERT INTO sys_menu (menu_id, menu_name, parent_id, order_num, path, component, menu_type, icon, visible, status, is_frame, is_cache, create_by, create_time, remark)
VALUES (2100, '租户代理', 2000, 1, '', '', 'M', 'el-icon-office-building', '0', '0', 0, 0, 'admin', NOW(), '顶部导航分组');

INSERT INTO sys_menu (menu_id, menu_name, parent_id, order_num, path, component, menu_type, icon, visible, status, is_frame, is_cache, create_by, create_time, remark)
VALUES
(2101, '代理管理', 2100, 1, 'proxy', 'admin/proxy/index', 'C', 'el-icon-user', '0', '0', 0, 0, 'admin', NOW(), NULL),
(2102, '收费配置', 2100, 2, 'serviceCost', 'admin/serviceCost/index', 'C', 'el-icon-price-tag', '0', '0', 0, 0, 'admin', NOW(), NULL),
(2103, '收益报表', 2100, 3, 'agentReport', 'admin/agentReport/index', 'C', 'el-icon-data-analysis', '0', '0', 0, 0, 'admin', NOW(), NULL),
(2104, '租户列表', 2100, 4, 'company', 'admin/sysCompany/index', 'C', 'el-icon-notebook-2', '0', '0', 0, 0, 'admin', NOW(), NULL),
(2105, '租户模块使用统计', 2100, 5, 'moduleUsage', 'admin/moduleUsage/index', 'C', 'el-icon-pie-chart', '0', '0', 0, 0, 'admin', NOW(), NULL),
(2106, '租户管理端菜单', 2100, 6, 'tenantMenu', 'admin/tenantMenu/index', 'C', 'el-icon-menu', '0', '0', 0, 0, 'admin', NOW(), '租户管理端菜单模板 CRUD'),
(2107, '租户销售端菜单', 2100, 7, 'tenantCompany', 'admin/tenantCompany/index', 'C', 'el-icon-s-grid', '0', '0', 0, 0, 'admin', NOW(), '租户销售端菜单模板 CRUD');

-- ============================================================================
-- 5. 分组 2：内容审计
-- ============================================================================
INSERT INTO sys_menu (menu_id, menu_name, parent_id, order_num, path, component, menu_type, icon, visible, status, is_frame, is_cache, create_by, create_time, remark)
VALUES (2200, '内容审计', 2000, 2, '', '', 'M', 'el-icon-view', '0', '0', 0, 0, 'admin', NOW(), '顶部导航分组');

INSERT INTO sys_menu (menu_id, menu_name, parent_id, order_num, path, component, menu_type, icon, visible, status, is_frame, is_cache, create_by, create_time, remark)
VALUES
(2201, '视频资源', 2200, 1, 'videoResource', 'admin/videoResource/index', 'C', 'el-icon-video-camera', '0', '0', 0, 0, 'admin', NOW(), NULL),
(2202, '公域课程管理', 2200, 2, 'course', 'admin/course/index', 'C', 'el-icon-reading', '0', '0', 0, 0, 'admin', NOW(), NULL),
(2203, '直播间', 2200, 3, 'live', 'admin/live/index', 'C', 'el-icon-video-camera-solid', '0', '0', 0, 0, 'admin', NOW(), NULL),
(2204, '直播视频', 2200, 4, 'liveVideo', 'admin/liveVideo/index', 'C', 'el-icon-film', '0', '0', 0, 0, 'admin', NOW(), NULL),
(2205, '商品管理', 2200, 5, 'product', 'admin/product/index', 'C', 'el-icon-goods', '0', '0', 0, 0, 'admin', NOW(), NULL),
(2206, '销售订单', 2200, 6, 'storeOrder', 'admin/storeOrder/index', 'C', 'el-icon-shopping-bag-1', '0', '0', 0, 0, 'admin', NOW(), NULL),
(2207, 'AI生成工作流', 2200, 7, 'workflowGenerate', 'lobster/workflow-generate/index', 'C', 'el-icon-cpu', '0', '0', 0, 0, 'admin', NOW(), NULL),
(2208, '销冠语料学习', 2200, 8, 'salesCorpus', 'lobster/sales-corpus/index', 'C', 'el-icon-trophy', '0', '0', 0, 0, 'admin', NOW(), NULL),
(2209, '文章管理', 2200, 9, 'article', 'admin/article/index', 'C', 'el-icon-document', '0', '0', 0, 0, 'admin', NOW(), NULL);

-- ============================================================================
-- 6. 分组 3：财务管理
-- ============================================================================
INSERT INTO sys_menu (menu_id, menu_name, parent_id, order_num, path, component, menu_type, icon, visible, status, is_frame, is_cache, create_by, create_time, remark)
VALUES (2300, '财务管理', 2000, 3, '', '', 'M', 'el-icon-money', '0', '0', 0, 0, 'admin', NOW(), '顶部导航分组');

INSERT INTO sys_menu (menu_id, menu_name, parent_id, order_num, path, component, menu_type, icon, visible, status, is_frame, is_cache, create_by, create_time, remark)
VALUES
(2301, '消费扣款记录', 2300, 1, 'consumeRecord', 'admin/consumeRecord/index', 'C', 'el-icon-wallet', '0', '0', 0, 0, 'admin', NOW(), NULL),
(2302, '模块消费统计', 2300, 2, 'consumeReport', 'admin/consumeReport/index', 'C', 'el-icon-pie-chart', '0', '0', 0, 0, 'admin', NOW(), NULL),
(2303, '充值扣款记录', 2300, 3, 'rechargeRecord', 'admin/rechargeRecord/index', 'C', 'el-icon-bank-card', '0', '0', 0, 0, 'admin', NOW(), NULL),
(2304, '返佣记录', 2300, 4, 'commissionRecord', 'admin/commissionRecord/index', 'C', 'el-icon-coin', '0', '0', 0, 0, 'admin', NOW(), NULL),
(2305, '代理提现管理', 2300, 5, 'withdrawal', 'admin/withdrawalManage/index', 'C', 'el-icon-money', '0', '0', 0, 0, 'admin', NOW(), NULL);

-- ============================================================================
-- 7. 分组 4：通信管理
-- ============================================================================
INSERT INTO sys_menu (menu_id, menu_name, parent_id, order_num, path, component, menu_type, icon, visible, status, is_frame, is_cache, create_by, create_time, remark)
VALUES (2400, '通信管理', 2000, 4, '', '', 'M', 'el-icon-phone-outline', '0', '0', 0, 0, 'admin', NOW(), '顶部导航分组');

INSERT INTO sys_menu (menu_id, menu_name, parent_id, order_num, path, component, menu_type, icon, visible, status, is_frame, is_cache, create_by, create_time, remark)
VALUES
(2401, '外呼管理', 2400, 1, 'voice', 'admin/voice/index', 'C', 'el-icon-phone', '0', '0', 0, 0, 'admin', NOW(), NULL),
(2402, '通话接口管理', 2400, 2, 'voiceApi', 'admin/voiceApi/index', 'C', 'el-icon-connection', '0', '0', 0, 0, 'admin', NOW(), NULL),
(2403, '通话套餐管理', 2400, 3, 'voicePackage', 'admin/voicePackage/index', 'C', 'el-icon-box', '0', '0', 0, 0, 'admin', NOW(), NULL),
(2404, '坐席管理', 2400, 4, 'voiceSeat', 'admin/voiceSeat/index', 'C', 'el-icon-service', '0', '0', 0, 0, 'admin', NOW(), NULL),
(2405, '黑名单管理', 2400, 5, 'voiceBlacklist', 'admin/voiceBlacklist/index', 'C', 'el-icon-warning', '0', '0', 0, 0, 'admin', NOW(), NULL),
(2406, '呼叫频率配置', 2400, 6, 'voiceFrequency', 'admin/voiceFrequency/index', 'C', 'el-icon-timer', '0', '0', 0, 0, 'admin', NOW(), NULL),
(2407, '通话套餐订单', 2400, 7, 'voiceOrder', 'admin/voiceOrder/index', 'C', 'el-icon-tickets', '0', '0', 0, 0, 'admin', NOW(), NULL),
(2408, '短信管理', 2400, 8, 'sms', 'admin/sms/index', 'C', 'el-icon-chat-dot-round', '0', '0', 0, 0, 'admin', NOW(), NULL),
(2409, '短信套餐', 2400, 9, 'smsPackage', 'admin/smsPackage/index', 'C', 'el-icon-box', '0', '0', 0, 0, 'admin', NOW(), NULL),
(2410, '短信订单', 2400, 10, 'smsOrder', 'admin/smsOrder/index', 'C', 'el-icon-tickets', '0', '0', 0, 0, 'admin', NOW(), NULL);

-- ============================================================================
-- 8. 分组 5：系统管理
-- ============================================================================
INSERT INTO sys_menu (menu_id, menu_name, parent_id, order_num, path, component, menu_type, icon, visible, status, is_frame, is_cache, create_by, create_time, remark)
VALUES (2500, '系统管理', 2000, 5, '', '', 'M', 'el-icon-setting', '0', '0', 0, 0, 'admin', NOW(), '顶部导航分组');

INSERT INTO sys_menu (menu_id, menu_name, parent_id, order_num, path, component, menu_type, icon, visible, status, is_frame, is_cache, create_by, create_time, remark)
VALUES
(2501, '员工管理', 2500, 1, 'sysUser', 'admin/sysUser/index', 'C', 'el-icon-user', '0', '0', 0, 0, 'admin', NOW(), NULL),
(2502, '角色管理', 2500, 2, 'role', 'system/role/index', 'C', 'el-icon-s-check', '0', '0', 0, 0, 'admin', NOW(), NULL),
(2503, '菜单管理', 2500, 3, 'menu', 'system/menu/index', 'C', 'el-icon-menu', '0', '0', 0, 0, 'admin', NOW(), NULL),
(2504, '部门管理', 2500, 4, 'dept', 'system/dept/index', 'C', 'el-icon-s-cooperation', '0', '0', 0, 0, 'admin', NOW(), NULL),
(2505, '岗位管理', 2500, 5, 'post', 'system/post/index', 'C', 'el-icon-s-custom', '0', '0', 0, 0, 'admin', NOW(), NULL),
(2506, '操作日志', 2500, 6, 'operLog', 'monitor/operlog/index', 'C', 'el-icon-document', '0', '0', 0, 0, 'admin', NOW(), NULL),
(2507, '登录日志', 2500, 7, 'loginLog', 'monitor/logininfor/index', 'C', 'el-icon-key', '0', '0', 0, 0, 'admin', NOW(), NULL),
(2508, '租户操作日志', 2500, 8, 'companyOperLog', 'monitor/componentsOperLog/index', 'C', 'el-icon-notebook-2', '0', '0', 0, 0, 'admin', NOW(), NULL),
(2509, '代理操作日志', 2500, 9, 'proxyOperLog', 'admin/proxyOperLog/index', 'C', 'el-icon-document-copy', '0', '0', 0, 0, 'admin', NOW(), NULL);

-- ============================================================================
-- 9. 分组 6：系统配置
-- ============================================================================
INSERT INTO sys_menu (menu_id, menu_name, parent_id, order_num, path, component, menu_type, icon, visible, status, is_frame, is_cache, create_by, create_time, remark)
VALUES (2600, '系统配置', 2000, 6, '', '', 'M', 'el-icon-s-tools', '0', '0', 0, 0, 'admin', NOW(), '顶部导航分组');

INSERT INTO sys_menu (menu_id, menu_name, parent_id, order_num, path, component, menu_type, icon, visible, status, is_frame, is_cache, create_by, create_time, remark)
VALUES
(2601, '字典管理', 2600, 1, 'dict', 'system/dict/index', 'C', 'el-icon-collection', '0', '0', 0, 0, 'admin', NOW(), NULL),
(2602, '参数管理', 2600, 2, 'config', 'system/config/index', 'C', 'el-icon-edit-outline', '0', '0', 0, 0, 'admin', NOW(), NULL),
(2603, '通知公告', 2600, 3, 'notice', 'system/notice/index', 'C', 'el-icon-bell', '0', '0', 0, 0, 'admin', NOW(), NULL),
(2604, '违规词语', 2600, 4, 'keyword', 'system/keyword/index', 'C', 'el-icon-warning-outline', '0', '0', 0, 0, 'admin', NOW(), NULL),
(2605, 'CID配置', 2600, 5, 'cidConfig', 'admin/cidConfig/index', 'C', 'el-icon-phone', '0', '0', 0, 0, 'admin', NOW(), NULL),
(2606, '个微配置', 2600, 6, 'wxConfig', 'admin/wxConfig/index', 'C', 'el-icon-chat-line-round', '0', '0', 0, 0, 'admin', NOW(), NULL),
(2607, 'OSS配置', 2600, 7, 'ossConfig', 'admin/ossConfig/index', 'C', 'el-icon-upload', '0', '0', 0, 0, 'admin', NOW(), NULL),
(2608, '前端配置', 2600, 8, 'frontConfig', 'admin/frontConfig/index', 'C', 'el-icon-monitor', '0', '0', 0, 0, 'admin', NOW(), NULL),
(2609, 'Ipad服务器', 2600, 9, 'ipadServer', 'admin/ipadServer/index', 'C', 'el-icon-mobile-phone', '0', '0', 0, 0, 'admin', NOW(), NULL),
(2610, '关键词管理', 2600, 10, 'keywordManage', 'admin/keywordManage/index', 'C', 'el-icon-search', '0', '0', 0, 0, 'admin', NOW(), NULL),
(2611, '文本模型配置', 2600, 11, 'textModel', 'admin/textModel/index', 'C', 'el-icon-cpu', '0', '0', 0, 0, 'admin', NOW(), NULL),
(2612, 'DB配置', 2600, 12, 'dbConfig', 'admin/dbConfig/index', 'C', 'el-icon-s-data', '0', '0', 0, 0, 'admin', NOW(), NULL);
