-- ============================================================================
-- 数字员工菜单同步到三张表
-- 1) 主库 ylrz_saas.tenant_sys_menu  ─ 全局系统菜单字典（最终 sys_menu 模板源）
-- 2) 主库 ylrz_saas.tenant_company_menu ─ 公司维度菜单分发（company_id=NULL 表通用）
-- 3) 租户库 fs_tenant_*.company_menu  ─ 当前租户内公司维度菜单（company_id=NULL 表通用）
--
-- 注意：tenant_company_menu / company_menu 比 tenant_sys_menu / sys_menu 多 company_id 列
--       tenant_sys_menu 比其他 menu 表多 query 列（其他表的同名意义可忽略）
-- ============================================================================

-- =========================================================
-- A) 主库 ylrz_saas.tenant_sys_menu —— 与 sys_menu 同步操作
-- =========================================================

-- A.1 父分组：对话测试与质量 / 多模型与配置
INSERT IGNORE INTO ylrz_saas.tenant_sys_menu
  (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time)
VALUES
(2994, '对话测试与质量', 2951, 5, 'lobsterChatTest', NULL, 1, 0, 'M', '0', '0', NULL, 'message', 'admin', NOW()),
(2995, '多模型与配置',   2951, 6, 'lobsterConfig',   NULL, 1, 0, 'M', '0', '0', NULL, 'tools',   'admin', NOW());

-- A.2 运维监控(2993)
INSERT IGNORE INTO ylrz_saas.tenant_sys_menu
  (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time)
VALUES
(2996, '任务执行(实例监控)', 2993, 1, 'lobster-instance',    'lobster/instance/index',    1, 0, 'C', '0', '0', 'workflow:lobster:instance', 'monitor', 'admin', NOW()),
(2997, 'Token消耗统计',      2993, 5, 'lobster-token-stats', 'lobster/token-stats/index', 1, 0, 'C', '0', '0', 'workflow:lobster:token',    'coin',    'admin', NOW());

-- A.3 语料与提示词(2992)
INSERT IGNORE INTO ylrz_saas.tenant_sys_menu
  (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time)
VALUES
(2998, '用户画像配置', 2992, 3, 'lobster-profile-config',  'lobster/profile-config/index',  1, 0, 'C', '0', '0', 'workflow:lobster:profile',   'user',     'admin', NOW()),
(3000, '消息去重配置', 2992, 5, 'lobster-dedup-config',    'lobster/dedup-config/index',    1, 0, 'C', '0', '0', 'workflow:lobster:dedup',     'filter',   'admin', NOW()),
(3001, '敏感词库',     2992, 6, 'lobster-sensitive-words', 'lobster/sensitive-words/index', 1, 0, 'C', '0', '0', 'workflow:lobster:sensitive', 'warning',  'admin', NOW());

-- A.4 对话测试与质量(2994)
INSERT IGNORE INTO ylrz_saas.tenant_sys_menu
  (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time)
VALUES
(3002, '聚合聊天',       2994, 1, 'lobster-chat-aggregate', 'lobster/chat-aggregate/index', 1, 0, 'C', '0', '0', 'workflow:lobster:chat',     'message',         'admin', NOW()),
(3003, '模拟聊天测试',   2994, 2, 'lobster-chat-test',      'lobster/chat-test/index',      1, 0, 'C', '0', '0', 'workflow:lobster:chattest', 'chat-dot-square', 'admin', NOW()),
(3004, '评分准确性验证', 2994, 3, 'lobster-quality-verify', 'lobster/quality-verify/index', 1, 0, 'C', '0', '0', 'workflow:lobster:quality',  'data-analysis',   'admin', NOW());

-- A.5 多模型与配置(2995)
INSERT IGNORE INTO ylrz_saas.tenant_sys_menu
  (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time)
VALUES
(3005, '多模型路由配置', 2995, 1, 'lobster-model-route', 'lobster/model-route/index', 1, 0, 'C', '0', '0', 'workflow:lobster:modelroute', 'guide', 'admin', NOW());

-- A.6 隐藏非数字员工业务菜单 + 工作流画布 + 新建工作流
UPDATE ylrz_saas.tenant_sys_menu SET visible = '1'
WHERE menu_id IN (2960,2961,2962,2963,2964,2965,2966,2967,2969,2970,2971,2972,2974,2975)
  AND parent_id IN (2951,2976);

-- =========================================================
-- B) 主库 ylrz_saas.tenant_company_menu —— 通用模板 company_id=NULL
-- =========================================================

INSERT IGNORE INTO ylrz_saas.tenant_company_menu
  (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, company_id)
VALUES
(2994, '对话测试与质量', 2951, 5, 'lobsterChatTest', NULL, 1, 0, 'M', '0', '0', NULL, 'message', 'admin', NOW(), NULL),
(2995, '多模型与配置',   2951, 6, 'lobsterConfig',   NULL, 1, 0, 'M', '0', '0', NULL, 'tools',   'admin', NOW(), NULL),
(2996, '任务执行(实例监控)', 2993, 1, 'lobster-instance',    'lobster/instance/index',    1, 0, 'C', '0', '0', 'workflow:lobster:instance', 'monitor', 'admin', NOW(), NULL),
(2997, 'Token消耗统计',      2993, 5, 'lobster-token-stats', 'lobster/token-stats/index', 1, 0, 'C', '0', '0', 'workflow:lobster:token',    'coin',    'admin', NOW(), NULL),
(2998, '用户画像配置', 2992, 3, 'lobster-profile-config',  'lobster/profile-config/index',  1, 0, 'C', '0', '0', 'workflow:lobster:profile',   'user',     'admin', NOW(), NULL),
(3000, '消息去重配置', 2992, 5, 'lobster-dedup-config',    'lobster/dedup-config/index',    1, 0, 'C', '0', '0', 'workflow:lobster:dedup',     'filter',   'admin', NOW(), NULL),
(3001, '敏感词库',     2992, 6, 'lobster-sensitive-words', 'lobster/sensitive-words/index', 1, 0, 'C', '0', '0', 'workflow:lobster:sensitive', 'warning',  'admin', NOW(), NULL),
(3002, '聚合聊天',       2994, 1, 'lobster-chat-aggregate', 'lobster/chat-aggregate/index', 1, 0, 'C', '0', '0', 'workflow:lobster:chat',     'message',         'admin', NOW(), NULL),
(3003, '模拟聊天测试',   2994, 2, 'lobster-chat-test',      'lobster/chat-test/index',      1, 0, 'C', '0', '0', 'workflow:lobster:chattest', 'chat-dot-square', 'admin', NOW(), NULL),
(3004, '评分准确性验证', 2994, 3, 'lobster-quality-verify', 'lobster/quality-verify/index', 1, 0, 'C', '0', '0', 'workflow:lobster:quality',  'data-analysis',   'admin', NOW(), NULL),
(3005, '多模型路由配置', 2995, 1, 'lobster-model-route',    'lobster/model-route/index',    1, 0, 'C', '0', '0', 'workflow:lobster:modelroute', 'guide', 'admin', NOW(), NULL);

UPDATE ylrz_saas.tenant_company_menu SET visible = '1'
WHERE menu_id IN (2960,2961,2962,2963,2964,2965,2966,2967,2969,2970,2971,2972,2974,2975)
  AND parent_id IN (2951,2976);
