-- ERP API管理菜单配置SQL脚本
-- 执行时间：2026-04-30
-- 说明：添加ERP管理模块到hzhub-system的菜单系统中

-- ERP管理菜单（一级菜单）
INSERT INTO sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, remark)
VALUES ('ERP管理', 0, 5, '/erp', NULL, 1, 0, 'M', '0', '0', '', 'monitor', 'admin', NOW(), 'ERP API管理目录');

-- API配置管理菜单（二级菜单）
INSERT INTO sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, remark)
VALUES ('API配置', (SELECT menu_id FROM (SELECT menu_id FROM sys_menu WHERE menu_name='ERP管理' AND parent_id=0) AS temp), 1, 'api', 'erp/api/index', 1, 0, 'C', '0', '0', 'erp:api:list', 'tool', 'admin', NOW(), 'API配置管理菜单');

-- API配置按钮权限
INSERT INTO sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time)
VALUES ('API查询', (SELECT menu_id FROM (SELECT menu_id FROM sys_menu WHERE menu_name='API配置' AND path='api') AS temp2), 1, '', NULL, 1, 0, 'F', '0', '0', 'erp:api:query', '#', 'admin', NOW());

INSERT INTO sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time)
VALUES ('API新增', (SELECT menu_id FROM (SELECT menu_id FROM sys_menu WHERE menu_name='API配置' AND path='api') AS temp2), 2, '', NULL, 1, 0, 'F', '0', '0', 'erp:api:add', '#', 'admin', NOW());

INSERT INTO sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time)
VALUES ('API修改', (SELECT menu_id FROM (SELECT menu_id FROM sys_menu WHERE menu_name='API配置' AND path='api') AS temp2), 3, '', NULL, 1, 0, 'F', '0', '0', 'erp:api:edit', '#', 'admin', NOW());

INSERT INTO sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time)
VALUES ('API删除', (SELECT menu_id FROM (SELECT menu_id FROM sys_menu WHERE menu_name='API配置' AND path='api') AS temp2), 4, '', NULL, 1, 0, 'F', '0', '0', 'erp:api:remove', '#', 'admin', NOW());

INSERT INTO sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time)
VALUES ('API测试', (SELECT menu_id FROM (SELECT menu_id FROM sys_menu WHERE menu_name='API配置' AND path='api') AS temp2), 5, '', NULL, 1, 0, 'F', '0', '0', 'erp:api:test', '#', 'admin', NOW());

-- API监控统计菜单（二级菜单）
INSERT INTO sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, remark)
VALUES ('API监控', (SELECT menu_id FROM (SELECT menu_id FROM sys_menu WHERE menu_name='ERP管理' AND parent_id=0) AS temp), 2, 'stats', 'erp/stats/index', 1, 0, 'C', '0', '0', 'erp:api:stats', 'monitor', 'admin', NOW(), 'API调用统计监控');