
-- 创建存储过程，作用是给按钮的 parent_id 赋值（菜单的 id）
-- 执行时要分布执行，先创建存储过程，然后执行其他语句，最好一句一句执行
CREATE OR REPLACE PROCEDURE system_menu_demo01_proc(IN_value IN INT)  
IS  
    v_local_variable INT;
BEGIN  
    -- 设置变量值  
    v_local_variable := IN_value;  
   
	-- 按钮 SQL
INSERT INTO system_menu(
    name, permission, type, sort, parent_id,
    path, icon, component, status
)
VALUES (
           'demo 代码自动生成查询', 'core:demo01:query', 3, 1, v_local_variable,
           '', '', '', 0
       );
INSERT INTO system_menu(
    name, permission, type, sort, parent_id,
    path, icon, component, status
)
VALUES (
           'demo 代码自动生成创建', 'core:demo01:create', 3, 2, v_local_variable,
           '', '', '', 0
       );
INSERT INTO system_menu(
    name, permission, type, sort, parent_id,
    path, icon, component, status
)
VALUES (
           'demo 代码自动生成更新', 'core:demo01:update', 3, 3, v_local_variable,
           '', '', '', 0
       );
INSERT INTO system_menu(
    name, permission, type, sort, parent_id,
    path, icon, component, status
)
VALUES (
           'demo 代码自动生成删除', 'core:demo01:delete', 3, 4, v_local_variable,
           '', '', '', 0
       );
INSERT INTO system_menu(
    name, permission, type, sort, parent_id,
    path, icon, component, status
)
VALUES (
           'demo 代码自动生成导出', 'core:demo01:export', 3, 5, v_local_variable,
           '', '', '', 0
       );
END;

-- 菜单 SQL
INSERT INTO system_menu(
    name, permission, type, sort, parent_id,
    path, icon, component, status, component_name
)
VALUES (
           'demo 代码自动生成管理', '', 2, 0, 1070,
           'demo01', '', 'core/demo01/index', 0, 'Demo01'
       );

CALL system_menu_demo01_proc(SELECT "id"  FROM  "system_menu" sm WHERE "name" = 'demo 代码自动生成管理');

DROP PROCEDURE system_menu_demo01_proc;


-- 创建存储过程，作用是给按钮的 parent_id 赋值（菜单的 id）
-- 执行时要分布执行，先创建存储过程，然后执行其他语句，最好一句一句执行
CREATE OR REPLACE PROCEDURE system_menu_core_area_proc(IN_value IN INT)
IS
v_local_variable INT;
BEGIN
-- 设置变量值
v_local_variable := IN_value;
    -- 按钮 SQL
INSERT INTO system_menu(
    name, permission, type, sort, parent_id,
    path, icon, component, status
)
VALUES (
           '行政区划查询', 'system:area:query', 3, 1, v_local_variable,
           '', '', '', 0
       );
INSERT INTO system_menu(
    name, permission, type, sort, parent_id,
    path, icon, component, status
)
VALUES (
           '行政区划创建', 'system:area:create', 3, 2, v_local_variable,
           '', '', '', 0
       );
INSERT INTO system_menu(
    name, permission, type, sort, parent_id,
    path, icon, component, status
)
VALUES (
           '行政区划更新', 'system:area:update', 3, 3, v_local_variable,
           '', '', '', 0
       );
INSERT INTO system_menu(
    name, permission, type, sort, parent_id,
    path, icon, component, status
)
VALUES (
           '行政区划删除', 'system:area:delete', 3, 4, v_local_variable,
           '', '', '', 0
       );
INSERT INTO system_menu(
    name, permission, type, sort, parent_id,
    path, icon, component, status
)
VALUES (
           '行政区划导出', 'system:area:export', 3, 5, v_local_variable,
           '', '', '', 0
       );
END;

-- 菜单 SQL
INSERT INTO system_menu(
    name, permission, type, sort, parent_id,
    path, icon, component, status, component_name
)
VALUES (
           '行政区划管理', '', 2, 0, 2,
           'area', '', 'system/area/index', 0, 'Area'
       );


CALL system_menu_core_area_proc(SELECT "id"  FROM  "system_menu" sm WHERE "name" = '行政区划管理');

DROP PROCEDURE system_menu_core_area_proc;