## 备注： 变量的使用方法，是mysql语法，基础生成部分是全数据库通用，若数据源非mysql，请只执行基础生成sql
START TRANSACTION;

-- 目录ID
set @pId = 目录ID;
-- 菜单ID
set @menuId = 菜单ID;

## -----------------基础生成部分start-------------
-- 插入菜单
INSERT INTO `sys_permission`
    (`id`, `parent_id`, `title`, `code`, `path`, `router_name`, `component`, `redirect`,  `icon`, `sort`, `keep_alive`, `hidden`, `type`, `deleted`, `create_time`, `update_time`)
VALUES
    (@menuId, @pId, '${comments}', NULL, '/${moduleName}/${pathName}', '${classname}', '${moduleName}/${pathName}/${className}Page', NULL, NULL, 1, 0, 0, 1, 0, NULL, '2019-10-13 22:00:24');


-- 菜单对应按钮SQL
INSERT INTO `sys_permission` ( `id`, `parent_id`,`title`, `code`, `sort`, `type`, `deleted`, `create_time`, `update_time` )
VALUES
( @menuId + 1, @menuId, '${comments}查询', '${moduleName}:${pathName}:read',  0, 2, 0, '2019-10-13 22:00:24', NULL );


INSERT INTO `sys_permission` ( `id`, `parent_id`,`title`, `code`, `sort`, `type`, `deleted`, `create_time`, `update_time` )
VALUES
( @menuId + 2, @menuId, '${comments}新增', '${moduleName}:${pathName}:add',  1, 2, 0, '2019-10-13 22:00:24', NULL );

INSERT INTO `sys_permission` ( `id`, `parent_id`,`title`, `code`, `sort`, `type`, `deleted`, `create_time`, `update_time` )
VALUES
( @menuId + 3, @menuId, '${comments}修改', '${moduleName}:${pathName}:edit', 2, 2, 0, '2019-10-13 22:00:24', NULL );

INSERT INTO `sys_permission` ( `id`, `parent_id`,`title`, `code`, `sort`, `type`, `deleted`, `create_time`, `update_time` )
VALUES
( @menuId + 4, @menuId, '${comments}删除', '${moduleName}:${pathName}:del', 3, 2, 0, '2019-10-13 22:00:24', NULL );

## -----------------基础生成部分end-------------

-- 清空变量
set @menuId = null;
set @pId = null;

COMMIT;