-- ============================================================
-- 菜单初始化SQL - 在RuoYi的sys_menu表中添加业务菜单
-- 请在达梦数据库中执行此脚本
-- ============================================================

-- 一级菜单：数据共享管理
INSERT INTO sys_menu (menu_name, parent_id, order_num, path, component, query, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, remark)
VALUES ('数据共享管理', 0, 10, 'gx', NULL, NULL, 1, 0, 'M', '0', '0', '', 'server', 'admin', SYSDATE, '数据共享管理目录');

-- 获取一级菜单ID (使用子查询)
-- 二级菜单：业务域管理
INSERT INTO sys_menu (menu_name, parent_id, order_num, path, component, query, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, remark)
SELECT '业务域管理', id, 1, 'biz', 'gx/biz/index', NULL, 1, 0, 'C', '0', '0', 'gx:biz:list', 'list', 'admin', SYSDATE, '业务域管理菜单'
FROM sys_menu WHERE menu_name = '数据共享管理' AND parent_id = 0;

INSERT INTO sys_menu (menu_name, parent_id, order_num, path, component, query, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, remark)
SELECT '站点管理', id, 2, 'station', 'gx/station/index', NULL, 1, 0, 'C', '0', '0', 'gx:station:list', 'server', 'admin', SYSDATE, '站点管理菜单'
FROM sys_menu WHERE menu_name = '数据共享管理' AND parent_id = 0;

INSERT INTO sys_menu (menu_name, parent_id, order_num, path, component, query, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, remark)
SELECT '共享申请', id, 3, 'apply', 'gx/apply/index', NULL, 1, 0, 'C', '0', '0', 'gx:apply:list', 'guide', 'admin', SYSDATE, '共享申请菜单'
FROM sys_menu WHERE menu_name = '数据共享管理' AND parent_id = 0;

INSERT INTO sys_menu (menu_name, parent_id, order_num, path, component, query, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, remark)
SELECT '交换日志', id, 4, 'log', 'gx/log/index', NULL, 1, 0, 'C', '0', '0', 'gx:log:list', 'log', 'admin', SYSDATE, '交换日志菜单'
FROM sys_menu WHERE menu_name = '数据共享管理' AND parent_id = 0;

INSERT INTO sys_menu (menu_name, parent_id, order_num, path, component, query, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, remark)
SELECT '数据质量', id, 5, 'quality', 'gx/quality/index', NULL, 1, 0, 'C', '0', '0', 'gx:quality:list', 'chart', 'admin', SYSDATE, '数据质量菜单'
FROM sys_menu WHERE menu_name = '数据共享管理' AND parent_id = 0;

INSERT INTO sys_menu (menu_name, parent_id, order_num, path, component, query, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, remark)
SELECT '单位管理', id, 6, 'unit', 'gx/unit/index', NULL, 1, 0, 'C', '0', '0', 'gx:unit:list', 'peoples', 'admin', SYSDATE, '单位管理菜单'
FROM sys_menu WHERE menu_name = '数据共享管理' AND parent_id = 0;

-- 按钮权限：业务域管理
INSERT INTO sys_menu (menu_name, parent_id, order_num, path, component, query, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, remark)
SELECT '业务域查询', id, 1, '', NULL, NULL, 1, 0, 'F', '0', '0', 'gx:biz:query', '#', 'admin', SYSDATE, ''
FROM sys_menu WHERE menu_name = '业务域管理' AND perms = 'gx:biz:list';

INSERT INTO sys_menu (menu_name, parent_id, order_num, path, component, query, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, remark)
SELECT '业务域新增', id, 2, '', NULL, NULL, 1, 0, 'F', '0', '0', 'gx:biz:add', '#', 'admin', SYSDATE, ''
FROM sys_menu WHERE menu_name = '业务域管理' AND perms = 'gx:biz:list';

INSERT INTO sys_menu (menu_name, parent_id, order_num, path, component, query, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, remark)
SELECT '业务域修改', id, 3, '', NULL, NULL, 1, 0, 'F', '0', '0', 'gx:biz:edit', '#', 'admin', SYSDATE, ''
FROM sys_menu WHERE menu_name = '业务域管理' AND perms = 'gx:biz:list';

INSERT INTO sys_menu (menu_name, parent_id, order_num, path, component, query, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, remark)
SELECT '业务域删除', id, 4, '', NULL, NULL, 1, 0, 'F', '0', '0', 'gx:biz:remove', '#', 'admin', SYSDATE, ''
FROM sys_menu WHERE menu_name = '业务域管理' AND perms = 'gx:biz:list';

INSERT INTO sys_menu (menu_name, parent_id, order_num, path, component, query, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, remark)
SELECT '业务域导出', id, 5, '', NULL, NULL, 1, 0, 'F', '0', '0', 'gx:biz:export', '#', 'admin', SYSDATE, ''
FROM sys_menu WHERE menu_name = '业务域管理' AND perms = 'gx:biz:list';

-- 按钮权限：站点管理
INSERT INTO sys_menu (menu_name, parent_id, order_num, path, component, query, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, remark)
SELECT '站点查询', id, 1, '', NULL, NULL, 1, 0, 'F', '0', '0', 'gx:station:query', '#', 'admin', SYSDATE, ''
FROM sys_menu WHERE menu_name = '站点管理' AND perms = 'gx:station:list';

INSERT INTO sys_menu (menu_name, parent_id, order_num, path, component, query, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, remark)
SELECT '站点新增', id, 2, '', NULL, NULL, 1, 0, 'F', '0', '0', 'gx:station:add', '#', 'admin', SYSDATE, ''
FROM sys_menu WHERE menu_name = '站点管理' AND perms = 'gx:station:list';

INSERT INTO sys_menu (menu_name, parent_id, order_num, path, component, query, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, remark)
SELECT '站点修改', id, 3, '', NULL, NULL, 1, 0, 'F', '0', '0', 'gx:station:edit', '#', 'admin', SYSDATE, ''
FROM sys_menu WHERE menu_name = '站点管理' AND perms = 'gx:station:list';

INSERT INTO sys_menu (menu_name, parent_id, order_num, path, component, query, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, remark)
SELECT '站点删除', id, 4, '', NULL, NULL, 1, 0, 'F', '0', '0', 'gx:station:remove', '#', 'admin', SYSDATE, ''
FROM sys_menu WHERE menu_name = '站点管理' AND perms = 'gx:station:list';

INSERT INTO sys_menu (menu_name, parent_id, order_num, path, component, query, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, remark)
SELECT '站点导出', id, 5, '', NULL, NULL, 1, 0, 'F', '0', '0', 'gx:station:export', '#', 'admin', SYSDATE, ''
FROM sys_menu WHERE menu_name = '站点管理' AND perms = 'gx:station:list';

-- 按钮权限：共享申请
INSERT INTO sys_menu (menu_name, parent_id, order_num, path, component, query, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, remark)
SELECT '申请查询', id, 1, '', NULL, NULL, 1, 0, 'F', '0', '0', 'gx:apply:query', '#', 'admin', SYSDATE, ''
FROM sys_menu WHERE menu_name = '共享申请' AND perms = 'gx:apply:list';

INSERT INTO sys_menu (menu_name, parent_id, order_num, path, component, query, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, remark)
SELECT '申请新增', id, 2, '', NULL, NULL, 1, 0, 'F', '0', '0', 'gx:apply:add', '#', 'admin', SYSDATE, ''
FROM sys_menu WHERE menu_name = '共享申请' AND perms = 'gx:apply:list';

INSERT INTO sys_menu (menu_name, parent_id, order_num, path, component, query, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, remark)
SELECT '申请审批', id, 3, '', NULL, NULL, 1, 0, 'F', '0', '0', 'gx:apply:edit', '#', 'admin', SYSDATE, ''
FROM sys_menu WHERE menu_name = '共享申请' AND perms = 'gx:apply:list';

INSERT INTO sys_menu (menu_name, parent_id, order_num, path, component, query, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, remark)
SELECT '申请删除', id, 4, '', NULL, NULL, 1, 0, 'F', '0', '0', 'gx:apply:remove', '#', 'admin', SYSDATE, ''
FROM sys_menu WHERE menu_name = '共享申请' AND perms = 'gx:apply:list';

COMMIT;
