-- ============================================================
-- adminUI 总后台菜单补充 - 通讯网关外呼/短信日志
-- 挂载到 通信管理(2400) 分组下
-- 数据来源：主库 comm_gateway_api_log
-- ============================================================

-- 外呼日志 (menu_id=2416)
INSERT INTO sys_menu (menu_id, menu_name, parent_id, order_num, path, component, menu_type, perms, icon, visible, status, is_frame, is_cache, create_by, create_time, remark)
SELECT 2416, '外呼日志', 2400, 13, 'commGatewayCallLog', 'admin/commGatewayCallLog/index', 'C', 'platform:commGatewayCallLog:list', 'el-icon-phone-outline', '0', '0', 0, 0, 'admin', NOW(), '通讯网关外呼调用日志'
FROM DUAL
WHERE NOT EXISTS (SELECT 1 FROM sys_menu WHERE menu_id = 2416);

INSERT INTO sys_menu (menu_id, menu_name, parent_id, order_num, path, component, menu_type, perms, icon, visible, status, is_frame, is_cache, create_by, create_time)
SELECT 24161, '外呼日志查询', 2416, 1, '', '', 'F', 'platform:commGatewayCallLog:query', '#', '0', '0', 0, 0, 'admin', NOW()
FROM DUAL
WHERE NOT EXISTS (SELECT 1 FROM sys_menu WHERE menu_id = 24161);

-- 短信日志 (menu_id=2417)
INSERT INTO sys_menu (menu_id, menu_name, parent_id, order_num, path, component, menu_type, perms, icon, visible, status, is_frame, is_cache, create_by, create_time, remark)
SELECT 2417, '短信日志', 2400, 14, 'commGatewaySmsLog', 'admin/commGatewaySmsLog/index', 'C', 'platform:commGatewaySmsLog:list', 'el-icon-message', '0', '0', 0, 0, 'admin', NOW(), '通讯网关短信发送日志'
FROM DUAL
WHERE NOT EXISTS (SELECT 1 FROM sys_menu WHERE menu_id = 2417);

INSERT INTO sys_menu (menu_id, menu_name, parent_id, order_num, path, component, menu_type, perms, icon, visible, status, is_frame, is_cache, create_by, create_time)
SELECT 24171, '短信日志查询', 2417, 1, '', '', 'F', 'platform:commGatewaySmsLog:query', '#', '0', '0', 0, 0, 'admin', NOW()
FROM DUAL
WHERE NOT EXISTS (SELECT 1 FROM sys_menu WHERE menu_id = 24171);

-- 关联 admin 角色(role_id=1)
INSERT INTO sys_role_menu (role_id, menu_id)
SELECT 1, 2416 FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM sys_role_menu WHERE role_id = 1 AND menu_id = 2416);
INSERT INTO sys_role_menu (role_id, menu_id)
SELECT 1, 24161 FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM sys_role_menu WHERE role_id = 1 AND menu_id = 24161);
INSERT INTO sys_role_menu (role_id, menu_id)
SELECT 1, 2417 FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM sys_role_menu WHERE role_id = 1 AND menu_id = 2417);
INSERT INTO sys_role_menu (role_id, menu_id)
SELECT 1, 24171 FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM sys_role_menu WHERE role_id = 1 AND menu_id = 24171);
