-- OCR测试页面菜单SQL
-- 注意：请根据实际情况调整parent_id（父菜单ID）

-- 获取系统工具菜单ID（通常是3）
SET @parentMenuId = (SELECT menu_id FROM sys_menu WHERE menu_name = '系统工具' AND parent_id = 0 LIMIT 1);

-- 如果没有系统工具菜单，则使用系统管理（parent_id=1）
SET @parentMenuId = IFNULL(@parentMenuId, 1);

-- 插入OCR测试菜单
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, update_by, update_time, remark)
SELECT 'OCR测试', @parentMenuId, 10, 'ocr', 'system/ocr/index', 1, 0, 'C', '0', '0', 'system:ocr:test', 'eye-open', 'admin', NOW(), '', NULL, 'OCR图像识别测试页面'
FROM DUAL
WHERE NOT EXISTS (
    SELECT 1 FROM sys_menu WHERE menu_name = 'OCR测试' AND perms = 'system:ocr:test'
);

-- 获取刚插入的OCR测试菜单ID
SET @ocrMenuId = (SELECT menu_id FROM sys_menu WHERE perms = 'system:ocr:test' LIMIT 1);

-- 插入OCR识别权限按钮
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, update_by, update_time, remark)
SELECT 'OCR识别', @ocrMenuId, 1, '#', '', 1, 0, 'F', '0', '0', 'system:ocr:recognize', '#', 'admin', NOW(), '', NULL, 'OCR图像识别权限'
FROM DUAL
WHERE NOT EXISTS (
    SELECT 1 FROM sys_menu WHERE perms = 'system:ocr:recognize'
);

-- 查询结果
SELECT 
    menu_id,
    menu_name,
    parent_id,
    path,
    component,
    perms,
    icon,
    '菜单添加成功' AS status
FROM sys_menu 
WHERE menu_name IN ('OCR测试', 'OCR识别')
ORDER BY menu_id;
