-- ============================================================================
-- sys_menu SQL for 基础信息管理子系统（14张业务表）
-- 包含: 项目/人员/机构/参建单位/分包单位/灌排渠道/行政区划/关联关系
-- PostgreSQL
-- ============================================================================

DO $$
DECLARE
    parent_menu_id BIGINT := 0;  -- ★ 修改为实际的父级菜单ID（0=根目录）★

    -- 一级目录
    base_dir_id       BIGINT;  -- 基础信息

    -- 二级目录
    proj_dir_id       BIGINT;  -- 项目管理
    pers_dir_id       BIGINT;  -- 人员管理
    org_dir_id        BIGINT;  -- 机构管理
    eng_dir_id        BIGINT;  -- 工程设施
    rel_dir_id        BIGINT;  -- 关联关系

    -- 临时变量
    menu_id           BIGINT;
    max_order         INT;
BEGIN
    -- ========================================================================
    -- 清理（支持重复执行）
    -- ========================================================================
    DELETE FROM sys_menu WHERE perms LIKE 'business:%';
    DELETE FROM sys_menu WHERE path IN ('base-dir','proj-dir','pers-dir','org-dir','eng-dir','rel-dir') AND menu_type = 'M';

    PERFORM setval('sys_menu_menu_id_seq', COALESCE((SELECT MAX(menu_id) FROM sys_menu), 0));
    SELECT COALESCE(MAX(order_num), 0) INTO max_order FROM sys_menu WHERE parent_id = parent_menu_id;

    -- ============================================================================
    -- 一、基础信息 一级目录
    -- ============================================================================
    max_order := max_order + 1;
    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 ('基础信息', 0, 10, 'base-dir', NULL, 1, 0, 'M', '0', '0', '', 'database', 'admin', now())
    RETURNING menu_id INTO base_dir_id;

    -- ============================================================================
    -- 二、项目管理 (projbase)
    -- ============================================================================
    max_order := max_order + 1;
    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 ('项目管理', base_dir_id, max_order, 'proj-dir', NULL, 1, 0, 'M', '0', '0', '', 'build', '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 ('项目基础信息', base_dir_id, (SELECT order_num FROM sys_menu WHERE menu_name = '项目管理' AND parent_id = base_dir_id), 'projbase', 'system/projbase/index', 1, 0, 'C', '0', '0', 'business:projbase:list', 'list', 'admin', now())
    RETURNING menu_id INTO menu_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, create_time) VALUES ('项目新增', menu_id, 1, '', '', 1, 0, 'F', '0', '0', 'business:projbase: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 ('项目修改', menu_id, 2, '', '', 1, 0, 'F', '0', '0', 'business:projbase: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 ('项目删除', menu_id, 3, '', '', 1, 0, 'F', '0', '0', 'business:projbase:remove', '#', 'admin', now());

    -- ============================================================================
    -- 三、人员管理 (persbase + persext)
    -- ============================================================================
    max_order := max_order + 1;
    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 ('人员管理', base_dir_id, max_order, 'pers-dir', NULL, 1, 0, 'M', '0', '0', '', 'peoples', '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 ('人员基础信息', base_dir_id, (SELECT order_num FROM sys_menu WHERE menu_name = '人员管理' AND parent_id = base_dir_id), 'persbase', 'system/persbase/index', 1, 0, 'C', '0', '0', 'business:persbase:list', 'list', 'admin', now())
    RETURNING menu_id INTO menu_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, create_time) VALUES ('人员新增', menu_id, 1, '', '', 1, 0, 'F', '0', '0', 'business:persbase: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 ('人员修改', menu_id, 2, '', '', 1, 0, 'F', '0', '0', 'business:persbase: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 ('人员删除', menu_id, 3, '', '', 1, 0, 'F', '0', '0', 'business:persbase: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 ('项目组成员', base_dir_id, (SELECT order_num+1 FROM sys_menu WHERE menu_name = '人员基础信息' AND parent_id = base_dir_id), 'persext', 'system/persext/index', 1, 0, 'C', '0', '0', 'business:persext:list', 'team', 'admin', now())
    RETURNING menu_id INTO menu_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, create_time) VALUES ('成员新增', menu_id, 1, '', '', 1, 0, 'F', '0', '0', 'business:persext: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 ('成员修改', menu_id, 2, '', '', 1, 0, 'F', '0', '0', 'business:persext: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 ('成员删除', menu_id, 3, '', '', 1, 0, 'F', '0', '0', 'business:persext:remove', '#', 'admin', now());

    -- ============================================================================
    -- 四、机构管理 (orgext + orguwatbase + orguwatext + orgwsub)
    -- ============================================================================
    max_order := max_order + 1;
    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 ('机构管理', base_dir_id, max_order, 'org-dir', NULL, 1, 0, 'M', '0', '0', '', 'tree-table', '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 ('水利机构扩展', base_dir_id, (SELECT order_num FROM sys_menu WHERE menu_name = '机构管理' AND parent_id = base_dir_id), 'orgext', 'system/orgext/index', 1, 0, 'C', '0', '0', 'business:orgext:list', 'guide', 'admin', now())
    RETURNING menu_id INTO menu_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, create_time) VALUES ('机构新增', menu_id, 1, '', '', 1, 0, 'F', '0', '0', 'business:orgext: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 ('机构修改', menu_id, 2, '', '', 1, 0, 'F', '0', '0', 'business:orgext: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 ('机构删除', menu_id, 3, '', '', 1, 0, 'F', '0', '0', 'business:orgext: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 ('参建单位信息', base_dir_id, (SELECT order_num+1 FROM sys_menu WHERE menu_name = '水利机构扩展' AND parent_id = base_dir_id), 'orguwatbase', 'system/orguwatbase/index', 1, 0, 'C', '0', '0', 'business:orguwatbase:list', 'company', 'admin', now())
    RETURNING menu_id INTO menu_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, create_time) VALUES ('单位新增', menu_id, 1, '', '', 1, 0, 'F', '0', '0', 'business:orguwatbase: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 ('单位修改', menu_id, 2, '', '', 1, 0, 'F', '0', '0', 'business:orguwatbase: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 ('单位删除', menu_id, 3, '', '', 1, 0, 'F', '0', '0', 'business:orguwatbase: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 ('参建单位扩展', base_dir_id, (SELECT order_num+1 FROM sys_menu WHERE menu_name = '参建单位信息' AND parent_id = base_dir_id), 'orguwatext', 'system/orguwatext/index', 1, 0, 'C', '0', '0', 'business:orguwatext:list', 'nested', 'admin', now())
    RETURNING menu_id INTO menu_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, create_time) VALUES ('扩展新增', menu_id, 1, '', '', 1, 0, 'F', '0', '0', 'business:orguwatext: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 ('扩展修改', menu_id, 2, '', '', 1, 0, 'F', '0', '0', 'business:orguwatext: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 ('扩展删除', menu_id, 3, '', '', 1, 0, 'F', '0', '0', 'business:orguwatext: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 ('分包单位信息', base_dir_id, (SELECT order_num+1 FROM sys_menu WHERE menu_name = '参建单位扩展' AND parent_id = base_dir_id), 'orgwsub', 'system/orgwsub/index', 1, 0, 'C', '0', '0', 'business:orgwsub:list', 'international', 'admin', now())
    RETURNING menu_id INTO menu_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, create_time) VALUES ('分包新增', menu_id, 1, '', '', 1, 0, 'F', '0', '0', 'business:orgwsub: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 ('分包修改', menu_id, 2, '', '', 1, 0, 'F', '0', '0', 'business:orgwsub: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 ('分包删除', menu_id, 3, '', '', 1, 0, 'F', '0', '0', 'business:orgwsub:remove', '#', 'admin', now());

    -- ============================================================================
    -- 五、工程设施 (irrchan + adbase)
    -- ============================================================================
    max_order := max_order + 1;
    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 ('工程设施', base_dir_id, max_order, 'eng-dir', NULL, 1, 0, 'M', '0', '0', '', 'color', '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 ('灌排渠道信息', base_dir_id, (SELECT order_num FROM sys_menu WHERE menu_name = '工程设施' AND parent_id = base_dir_id), 'irrchan', 'system/irrchan/index', 1, 0, 'C', '0', '0', 'business:irrchan:list', 'route', 'admin', now())
    RETURNING menu_id INTO menu_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, create_time) VALUES ('渠道新增', menu_id, 1, '', '', 1, 0, 'F', '0', '0', 'business:irrchan: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 ('渠道修改', menu_id, 2, '', '', 1, 0, 'F', '0', '0', 'business:irrchan: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 ('渠道删除', menu_id, 3, '', '', 1, 0, 'F', '0', '0', 'business:irrchan: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 ('行政区划信息', base_dir_id, (SELECT order_num+1 FROM sys_menu WHERE menu_name = '灌排渠道信息' AND parent_id = base_dir_id), 'adbase', 'system/adbase/index', 1, 0, 'C', '0', '0', 'business:adbase:list', 'map', 'admin', now())
    RETURNING menu_id INTO menu_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, create_time) VALUES ('区划新增', menu_id, 1, '', '', 1, 0, 'F', '0', '0', 'business:adbase: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 ('区划修改', menu_id, 2, '', '', 1, 0, 'F', '0', '0', 'business:adbase: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 ('区划删除', menu_id, 3, '', '', 1, 0, 'F', '0', '0', 'business:adbase:remove', '#', 'admin', now());

    -- ============================================================================
    -- 六、关联关系 (5张关系表)
    -- ============================================================================
    max_order := max_order + 1;
    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 ('关联关系', base_dir_id, max_order, 'rel-dir', NULL, 1, 0, 'M', '0', '0', '', 'link', '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 ('工程-水利机构', base_dir_id, (SELECT order_num FROM sys_menu WHERE menu_name = '关联关系' AND parent_id = base_dir_id), 'relengorg', 'system/relengorg/index', 1, 0, 'C', '0', '0', 'business:relengorg:list', 'connection', 'admin', now())
    RETURNING menu_id INTO menu_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, create_time) VALUES ('关联新增', menu_id, 1, '', '', 1, 0, 'F', '0', '0', 'business:relengorg: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 ('关联修改', menu_id, 2, '', '', 1, 0, 'F', '0', '0', 'business:relengorg: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 ('关联删除', menu_id, 3, '', '', 1, 0, 'F', '0', '0', 'business:relengorg: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 ('工程-参建单位', base_dir_id, (SELECT order_num+1 FROM sys_menu WHERE menu_name = '工程-水利机构' AND parent_id = base_dir_id), 'relengorguwat', 'system/relengorguwat/index', 1, 0, 'C', '0', '0', 'business:relengorguwat:list', 'connection', 'admin', now())
    RETURNING menu_id INTO menu_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, create_time) VALUES ('关联新增', menu_id, 1, '', '', 1, 0, 'F', '0', '0', 'business:relengorguwat: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 ('关联修改', menu_id, 2, '', '', 1, 0, 'F', '0', '0', 'business:relengorguwat: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 ('关联删除', menu_id, 3, '', '', 1, 0, 'F', '0', '0', 'business:relengorguwat: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 ('项目-机构关系', base_dir_id, (SELECT order_num+1 FROM sys_menu WHERE menu_name = '工程-参建单位' AND parent_id = base_dir_id), 'relprojorg', 'system/relprojorg/index', 1, 0, 'C', '0', '0', 'business:relprojorg:list', 'connection', 'admin', now())
    RETURNING menu_id INTO menu_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, create_time) VALUES ('关联新增', menu_id, 1, '', '', 1, 0, 'F', '0', '0', 'business:relprojorg: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 ('关联修改', menu_id, 2, '', '', 1, 0, 'F', '0', '0', 'business:relprojorg: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 ('关联删除', menu_id, 3, '', '', 1, 0, 'F', '0', '0', 'business:relprojorg: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 ('标段-参建单位', base_dir_id, (SELECT order_num+1 FROM sys_menu WHERE menu_name = '项目-机构关系' AND parent_id = base_dir_id), 'reltendorg', 'system/reltendorg/index', 1, 0, 'C', '0', '0', 'business:reltendorg:list', 'connection', 'admin', now())
    RETURNING menu_id INTO menu_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, create_time) VALUES ('关联新增', menu_id, 1, '', '', 1, 0, 'F', '0', '0', 'business:reltendorg: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 ('关联修改', menu_id, 2, '', '', 1, 0, 'F', '0', '0', 'business:reltendorg: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 ('关联删除', menu_id, 3, '', '', 1, 0, 'F', '0', '0', 'business:reltendorg: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 ('用户-标段关系', base_dir_id, (SELECT order_num+1 FROM sys_menu WHERE menu_name = '标段-参建单位' AND parent_id = base_dir_id), 'relusertend', 'system/relusertend/index', 1, 0, 'C', '0', '0', 'business:relusertend:list', 'connection', 'admin', now())
    RETURNING menu_id INTO menu_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, create_time) VALUES ('关联新增', menu_id, 1, '', '', 1, 0, 'F', '0', '0', 'business:relusertend: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 ('关联修改', menu_id, 2, '', '', 1, 0, 'F', '0', '0', 'business:relusertend: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 ('关联删除', menu_id, 3, '', '', 1, 0, 'F', '0', '0', 'business:relusertend:remove', '#', 'admin', now());

    -- ========================================================================
    -- 完成
    -- ========================================================================
    RAISE NOTICE '========================================';
    RAISE NOTICE '基础信息管理子系统菜单 SQL 执行完成!';
    RAISE NOTICE 'parent_menu_id = %', parent_menu_id;
    RAISE NOTICE '共插入 14 个菜单项 + 42 个按钮权限';
    RAISE NOTICE '========================================';
END $$;
