-- 为新的行情数据页面添加菜单配置

-- 1. 首先查询股票系统的父菜单ID
SELECT menu_id, menu_name, parent_id FROM sys_menu WHERE menu_name = '股票系统';

-- 2. 假设股票系统的父菜单ID为某个值，添加新的行情数据菜单项
-- 请根据实际查询结果修改parent_id的值

-- 插入新的行情数据菜单项
INSERT INTO sys_menu (
    menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by
) VALUES (
    '新行情数据', 
    (SELECT menu_id FROM sys_menu WHERE menu_name = '股票系统'), 
    '10', 
    'newstocks', 
    'stocksystem/newstocks', 
    '1', 
    '0', 
    'C', 
    '0', 
    '0', 
    'stocksystem:newstocks:list', 
    'chart', 
    'admin'
);

-- 3. 为新的行情数据页面添加按钮权限
-- 获取新插入的菜单ID
SET @menu_id = LAST_INSERT_ID();

-- 插入新增按钮权限
INSERT INTO sys_menu (
    menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by
) VALUES (
    '新增', 
    @menu_id, 
    '1', 
    '#', 
    NULL, 
    '1', 
    '0', 
    'F', 
    '0', 
    '0', 
    'stocksystem:newstocks:add', 
    '#', 
    'admin'
);

-- 插入修改按钮权限
INSERT INTO sys_menu (
    menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by
) VALUES (
    '修改', 
    @menu_id, 
    '2', 
    '#', 
    NULL, 
    '1', 
    '0', 
    'F', 
    '0', 
    '0', 
    'stocksystem:newstocks:edit', 
    '#', 
    'admin'
);

-- 插入删除按钮权限
INSERT INTO sys_menu (
    menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by
) VALUES (
    '删除', 
    @menu_id, 
    '3', 
    '#', 
    NULL, 
    '1', 
    '0', 
    'F', 
    '0', 
    '0', 
    'stocksystem:newstocks:remove', 
    '#', 
    'admin'
);

-- 插入导出按钮权限
INSERT INTO sys_menu (
    menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by
) VALUES (
    '导出', 
    @menu_id, 
    '4', 
    '#', 
    NULL, 
    '1', 
    '0', 
    'F', 
    '0', 
    '0', 
    'stocksystem:newstocks:export', 
    '#', 
    'admin'
);

-- 4. 查询结果
SELECT * FROM sys_menu WHERE menu_name LIKE '%新行情数据%' OR parent_id = @menu_id;