-- =====================================================
-- 龙虾引擎 公司端 (saasui) 菜单初始化
-- 运行目标：各租户数据库 (tenant_xxx)
-- 
-- 运行方式：
--   1. 已有租户：直接在各租户库执行本脚本
--   2. 新租户：需确保 tenant_company_menu 模板表也包含这些条目
-- =====================================================

-- 1. 根菜单：龙虾引擎 (parent_id=0 作为顶层菜单)
INSERT IGNORE INTO company_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 (29900, '龙虾引擎', 0, 100, '/lobster', '', 'M', 'el-icon-cpu', '0', '0', 0, 0, 'admin', NOW(), 'Lobster Workflow Engine顶层菜单');

-- 2. 模拟聊天测试
INSERT IGNORE INTO company_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 (29920, '模拟聊天测试', 29900, 13, 'chat-test', 'lobster/chat-test/index', 'C', 'el-icon-chat-dot-square', '0', '0', 0, 0, 'admin', NOW(), NULL);

-- 3. 评分准确性验证
INSERT IGNORE INTO company_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 (29921, '评分准确性验证', 29900, 14, 'quality-verify', 'lobster/quality-verify/index', 'C', 'el-icon-data-analysis', '0', '0', 0, 0, 'admin', NOW(), NULL);

-- 4. 用户画像配置
INSERT IGNORE INTO company_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 (29922, '用户画像配置', 29900, 15, 'profile-config', 'lobster/profile-config/index', 'C', 'el-icon-user', '0', '0', 0, 0, 'admin', NOW(), NULL);

-- 5. 摘要生成配置
INSERT IGNORE INTO company_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 (29923, '摘要生成配置', 29900, 16, 'summary-config', 'lobster/summary-config/index', 'C', 'el-icon-notebook', '0', '0', 0, 0, 'admin', NOW(), NULL);

-- 6. 消息去重配置
INSERT IGNORE INTO company_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 (29924, '消息去重配置', 29900, 17, 'dedup-config', 'lobster/dedup-config/index', 'C', 'el-icon-filter', '0', '0', 0, 0, 'admin', NOW(), NULL);

-- 7. 敏感词库
INSERT IGNORE INTO company_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 (29925, '敏感词库', 29900, 18, 'sensitive-words', 'lobster/sensitive-words/index', 'C', 'el-icon-warning', '0', '0', 0, 0, 'admin', NOW(), NULL);

-- 8. 节点详情 (hidden, 从实例页跳转)
INSERT IGNORE INTO company_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 (29926, '节点详情', 29900, 19, 'node-detail', 'lobster/node-detail/index', 'C', 'el-icon-document', '1', '0', 0, 0, 'admin', NOW(), '从实例监控页跳转');

-- =====================================================
-- 同步更新模板表 tenant_company_menu（新租户创建时从此表复制）
-- 注意：此 SQL 在 ADMIN 库执行
-- =====================================================
-- 如果要在 ADMIN 库更新模板表，请运行以下语句：
-- INSERT IGNORE INTO tenant_company_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)
-- SELECT menu_id, menu_name, parent_id, order_num, path, component, menu_type, icon, visible, status, is_frame, is_cache, create_by, create_time, remark
-- FROM company_menu WHERE menu_id IN (29900,29920,29921,29922,29923,29924,29925,29926);

-- =====================================================
-- 菜单授权（根据实际role_id调整）
-- SELECT role_id FROM company_role WHERE role_key = 'tenant_admin';
-- INSERT IGNORE INTO company_role_menu (role_id, menu_id)
-- SELECT <role_id>, menu_id FROM company_menu WHERE menu_id IN (29900,29920,29921,29922,29923,29924,29925,29926);
-- =====================================================
