-- ----------------------------
-- 菜单权限表
-- ----------------------------
DROP TABLE IF EXISTS sys_menu;

CREATE TABLE sys_menu
(
    menu_id     BIGSERIAL   NOT NULL PRIMARY KEY,
    menu_name   VARCHAR(50) NOT NULL,
    parent_id   BIGINT       DEFAULT 0,
    order_num   INTEGER      DEFAULT 0,
    path        VARCHAR(200) DEFAULT '',
    component   VARCHAR(255) DEFAULT NULL,
    query       VARCHAR(255) DEFAULT NULL,
    route_name  VARCHAR(50)  DEFAULT '',
    is_frame    INTEGER      DEFAULT 1,
    is_cache    INTEGER      DEFAULT 0,
    menu_type   CHAR(1)      DEFAULT '',
    visible     CHAR(1)      DEFAULT '0',
    status      CHAR(1)      DEFAULT '0',
    perms       VARCHAR(100) DEFAULT NULL,
    icon        VARCHAR(100) DEFAULT '#',
    create_by   VARCHAR(64)  DEFAULT '',
    create_time TIMESTAMP,
    update_by   VARCHAR(64)  DEFAULT '',
    update_time TIMESTAMP,
    remark      VARCHAR(500) DEFAULT ''
);

COMMENT ON TABLE sys_menu IS '菜单权限表';

-- Optional: Set comments on the columns
COMMENT ON COLUMN sys_menu.menu_id IS '菜单ID';
COMMENT ON COLUMN sys_menu.menu_name IS '菜单名称';
COMMENT ON COLUMN sys_menu.parent_id IS '父菜单ID';
COMMENT ON COLUMN sys_menu.order_num IS '显示顺序';
COMMENT ON COLUMN sys_menu.path IS '路由地址';
COMMENT ON COLUMN sys_menu.component IS '组件路径';
COMMENT ON COLUMN sys_menu.query IS '路由参数';
COMMENT ON COLUMN sys_menu.route_name IS '路由名称';
COMMENT ON COLUMN sys_menu.is_frame IS '是否为外链（0是 1否）';
COMMENT ON COLUMN sys_menu.is_cache IS '是否缓存（0缓存 1不缓存）';
COMMENT ON COLUMN sys_menu.menu_type IS '菜单类型（M目录 C菜单 F按钮）';
COMMENT ON COLUMN sys_menu.visible IS '菜单状态（0显示 1隐藏）';
COMMENT ON COLUMN sys_menu.status IS '菜单状态（0正常 1停用）';
COMMENT ON COLUMN sys_menu.perms IS '权限标识';
COMMENT ON COLUMN sys_menu.icon IS '菜单图标';
COMMENT ON COLUMN sys_menu.create_by IS '创建者';
COMMENT ON COLUMN sys_menu.create_time IS '创建时间';
COMMENT ON COLUMN sys_menu.update_by IS '更新者';
COMMENT ON COLUMN sys_menu.update_time IS '更新时间';
COMMENT ON COLUMN sys_menu.remark IS '备注';


-- ----------------------------
-- 初始化-菜单信息表数据
-- ----------------------------
-- 一级菜单
insert into sys_menu (id, name, parent_id, order_num, perms, url, target, icon, visible, status, menu_type, is_frame,
                      is_cache, code, create_by, create_time, update_by, update_time, remark)
values ('1', '系统管理', '0', '1', 'system', null, '', '', 1, 0, 'M', '0', '0', '', 'system', 'admin',
        CURRENT_TIMESTAMP, '', null, '系统管理目录'),
       ('2', '系统监控', '0', '2', 'monitor', null, '', '', 1, 0, 'M', '0', '0', '', 'monitor', 'admin',
        CURRENT_TIMESTAMP, '', null, '系统监控目录'),
       ('3', '系统工具', '0', '3', 'tool', null, '', '', 1, 0, 'M', '0', '0', '', 'tool', 'admin', CURRENT_TIMESTAMP,
        '', null, '系统工具目录'),
       ('4', '若依官网', '0', '4', 'http://ruoyi.vip', null, '', '', 0, 0, 'M', '0', '0', '', 'guide', 'admin',
        CURRENT_TIMESTAMP, '', null, '若依官网地址');

-- 二级菜单
insert into sys_menu (id, name, parent_id, order_num, perms, url, target, icon, visible, status, menu_type, is_frame,
                      is_cache, code, create_by, create_time, update_by, update_time, remark)
values ('100', '用户管理', '1', '1', 'user', 'system/user/index', '', '', 1, 0, 'C', '0', '0', 'system:user:list',
        'user', 'admin', CURRENT_TIMESTAMP, '', null, '用户管理菜单'),
       ('101', '角色管理', '1', '2', 'role', 'system/role/index', '', '', 1, 0, 'C', '0', '0', 'system:role:list',
        'peoples', 'admin', CURRENT_TIMESTAMP, '', null, '角色管理菜单'),
       ('102', '菜单管理', '1', '3', 'menu', 'system/menu/index', '', '', 1, 0, 'C', '0', '0', 'system:menu:list',
        'tree-table', 'admin', CURRENT_TIMESTAMP, '', null, '菜单管理菜单'),
       ('103', '部门管理', '1', '4', 'dept', 'system/dept/index', '', '', 1, 0, 'C', '0', '0', 'system:dept:list',
        'tree', 'admin', CURRENT_TIMESTAMP, '', null, '部门管理菜单'),
       ('104', '岗位管理', '1', '5', 'post', 'system/post/index', '', '', 1, 0, 'C', '0', '0', 'system:post:list',
        'post', 'admin', CURRENT_TIMESTAMP, '', null, '岗位管理菜单'),
       ('105', '字典管理', '1', '6', 'dict', 'system/dict/index', '', '', 1, 0, 'C', '0', '0', 'system:dict:list',
        'dict', 'admin', CURRENT_TIMESTAMP, '', null, '字典管理菜单'),
       ('106', '参数设置', '1', '7', 'config', 'system/config/index', '', '', 1, 0, 'C', '0', '0', 'system:config:list',
        'edit', 'admin', CURRENT_TIMESTAMP, '', null, '参数设置菜单'),
       ('107', '通知公告', '1', '8', 'notice', 'system/notice/index', '', '', 1, 0, 'C', '0', '0', 'system:notice:list',
        'message', 'admin', CURRENT_TIMESTAMP, '', null, '通知公告菜单'),
       ('108', '日志管理', '1', '9', 'log', '', '', '', 1, 0, 'M', '0', '0', '', 'log', 'admin', CURRENT_TIMESTAMP, '',
        null, '日志管理菜单'),
       ('109', '在线用户', '2', '1', 'online', 'monitor/online/index', '', '', 1, 0, 'C', '0', '0',
        'monitor:online:list', 'online', 'admin', CURRENT_TIMESTAMP, '', null, '在线用户菜单'),
       ('110', '定时任务', '2', '2', 'job', 'monitor/job/index', '', '', 1, 0, 'C', '0', '0', 'monitor:job:list', 'job',
        'admin', CURRENT_TIMESTAMP, '', null, '定时任务菜单'),
       ('111', '数据监控', '2', '3', 'druid', 'monitor/druid/index', '', '', 1, 0, 'C', '0', '0', 'monitor:druid:list',
        'druid', 'admin', CURRENT_TIMESTAMP, '', null, '数据监控菜单'),
       ('112', '服务监控', '2', '4', 'server', 'monitor/server/index', '', '', 1, 0, 'C', '0', '0',
        'monitor:server:list', 'server', 'admin', CURRENT_TIMESTAMP, '', null, '服务监控菜单'),
       ('113', '缓存监控', '2', '5', 'cache', 'monitor/cache/index', '', '', 1, 0, 'C', '0', '0', 'monitor:cache:list',
        'redis', 'admin', CURRENT_TIMESTAMP, '', null, '缓存监控菜单'),
       ('114', '缓存列表', '2', '6', 'cacheList', 'monitor/cache/list', '', '', 1, 0, 'C', '0', '0',
        'monitor:cache:list', 'redis-list', 'admin', CURRENT_TIMESTAMP, '', null, '缓存列表菜单'),
       ('115', '表单构建', '3', '1', 'build', 'tool/build/index', '', '', 1, 0, 'C', '0', '0', 'tool:build:list',
        'build', 'admin', CURRENT_TIMESTAMP, '', null, '表单构建菜单'),
       ('116', '代码生成', '3', '2', 'gen', 'tool/gen/index', '', '', 1, 0, 'C', '0', '0', 'tool:gen:list', 'code',
        'admin', CURRENT_TIMESTAMP, '', null, '代码生成菜单'),
       ('117', '系统接口', '3', '3', 'swagger', 'tool/swagger/index', '', '', 1, 0, 'C', '0', '0', 'tool:swagger:list',
        'swagger', 'admin', CURRENT_TIMESTAMP, '', null, '系统接口菜单');

-- 三级菜单
insert into sys_menu (id, name, parent_id, order_num, perms, url, target, icon, visible, status, menu_type, is_frame,
                      is_cache, code, create_by, create_time, update_by, update_time, remark)
values ('500', '操作日志', '108', '1', 'operlog', 'monitor/operlog/index', '', '', 1, 0, 'C', '0', '0',
        'monitor:operlog:list', 'form', 'admin', CURRENT_TIMESTAMP, '', null, '操作日志菜单'),
       ('501', '登录日志', '108', '2', 'logininfor', 'monitor/logininfor/index', '', '', 1, 0, 'C', '0', '0',
        'monitor:logininfor:list', 'logininfor', 'admin', CURRENT_TIMESTAMP, '', null, '登录日志菜单');

-- 用户管理按钮
insert into sys_menu (id, name, parent_id, order_num, perms, url, target, icon, visible, status, menu_type, is_frame,
                      is_cache, code, create_by, create_time, update_by, update_time, remark)
values ('1000', '用户查询', '100', '1', '', '', '', '', 1, 0, 'F', '0', '0', 'system:user:query', '#', 'admin',
        CURRENT_TIMESTAMP, '', null, ''),
       ('1001', '用户新增', '100', '2', '', '', '', '', 1, 0, 'F', '0', '0', 'system:user:add', '#', 'admin',
        CURRENT_TIMESTAMP, '', null, ''),
       ('1002', '用户修改', '100', '3', '', '', '', '', 1, 0, 'F', '0', '0', 'system:user:edit', '#', 'admin',
        CURRENT_TIMESTAMP, '', null, '');

insert into sys_menu (menu_id, menu_name, parent_id, order_num, perms, url, target, icon, visible, status, is_cache,
                      del_flag, create_by, create_time, update_by, update_time, remarks)
values ('1003', '用户删除', '100', '4', '', '', '', '', 1, 0, 'F', '0', 'admin', current_timestamp, '',
        current_timestamp, ''),
       ('1004', '用户导出', '100', '5', '', '', '', '', 1, 0, 'F', '0', 'admin', current_timestamp, '',
        current_timestamp, ''),
       ('1005', '用户导入', '100', '6', '', '', '', '', 1, 0, 'F', '0', 'admin', current_timestamp, '',
        current_timestamp, ''),
       ('1006', '重置密码', '100', '7', '', '', '', '', 1, 0, 'F', '0', 'admin', current_timestamp, '',
        current_timestamp, ''),
-- 角色管理按钮
       ('1007', '角色查询', '101', '1', '', '', '', '', 1, 0, 'F', '0', 'admin', current_timestamp, '',
        current_timestamp, ''),
       ('1008', '角色新增', '101', '2', '', '', '', '', 1, 0, 'F', '0', 'admin', current_timestamp, '',
        current_timestamp, ''),
       ('1009', '角色修改', '101', '3', '', '', '', '', 1, 0, 'F', '0', 'admin', current_timestamp, '',
        current_timestamp, ''),
       ('1010', '角色删除', '101', '4', '', '', '', '', 1, 0, 'F', '0', 'admin', current_timestamp, '',
        current_timestamp, ''),
       ('1011', '角色导出', '101', '5', '', '', '', '', 1, 0, 'F', '0', 'admin', current_timestamp, '',
        current_timestamp, ''),
-- 菜单管理按钮
       ('1012', '菜单查询', '102', '1', '', '', '', '', 1, 0, 'F', '0', 'admin', current_timestamp, '',
        current_timestamp, ''),
       ('1013', '菜单新增', '102', '2', '', '', '', '', 1, 0, 'F', '0', 'admin', current_timestamp, '',
        current_timestamp, ''),
       ('1014', '菜单修改', '102', '3', '', '', '', '', 1, 0, 'F', '0', 'admin', current_timestamp, '',
        current_timestamp, ''),
       ('1015', '菜单删除', '102', '4', '', '', '', '', 1, 0, 'F', '0', 'admin', current_timestamp, '',
        current_timestamp, ''),
-- 部门管理按钮
       ('1016', '部门查询', '103', '1', '', '', '', '', 1, 0, 'F', '0', 'admin', current_timestamp, '',
        current_timestamp, ''),
       ('1017', '部门新增', '103', '2', '', '', '', '', 1, 0, 'F', '0', 'admin', current_timestamp, '',
        current_timestamp, ''),
       ('1018', '部门修改', '103', '3', '', '', '', '', 1, 0, 'F', '0', 'admin', current_timestamp, '',
        current_timestamp, ''),
       ('1019', '部门删除', '103', '4', '', '', '', '', 1, 0, 'F', '0', 'admin', current_timestamp, '',
        current_timestamp, ''),
-- 岗位管理按钮
       ('1020', '岗位查询', '104', '1', '', '', '', '', 1, 0, 'F', '0', 'admin', current_timestamp, '',
        current_timestamp, ''),
       ('1021', '岗位新增', '104', '2', '', '', '', '', 1, 0, 'F', '0', 'admin', current_timestamp, '',
        current_timestamp, ''),
       ('1022', '岗位修改', '104', '3', '', '', '', '', 1, 0, 'F', '0', 'admin', current_timestamp, '',
        current_timestamp, ''),
       ('1023', '岗位删除', '104', '4', '', '', '', '', 1, 0, 'F', '0', 'admin', current_timestamp, '',
        current_timestamp, ''),
       ('1024', '岗位导出', '104', '5', '', '', '', '', 1, 0, 'F', '0', 'admin', current_timestamp, '',
        current_timestamp, ''),
-- 字典管理按钮
       ('1025', '字典查询', '105', '1', '#', '', '', '', 1, 0, 'F', '0', 'admin', current_timestamp, '',
        current_timestamp, ''),
       ('1026', '字典新增', '105', '2', '#', '', '', '', 1, 0, 'F', '0', 'admin', current_timestamp, '',
        current_timestamp, ''),
       ('1027', '字典修改', '105', '3', '#', '', '', '', 1, 0, 'F', '0', 'admin', current_timestamp, '',
        current_timestamp, ''),
       ('1028', '字典删除', '105', '4', '#', '', '', '', 1, 0, 'F', '0', 'admin', current_timestamp, '',
        current_timestamp, ''),
       ('1029', '字典导出', '105', '5', '#', '', '', '', 1, 0, 'F', '0', 'admin', current_timestamp, '',
        current_timestamp, ''),
-- 参数设置按钮
       ('1030', '参数查询', '106', '1', '#', '', '', '', 1, 0, 'F', '0', 'admin', current_timestamp, '',
        current_timestamp, ''),
       ('1031', '参数新增', '106', '2', '#', '', '', '', 1, 0, 'F', '0', 'admin', current_timestamp, '',
        current_timestamp, ''),
       ('1032', '参数修改', '106', '3', '#', '', '', '', 1, 0, 'F', '0', 'admin', current_timestamp, '',
        current_timestamp, ''),
       ('1033', '参数删除', '106', '4', '#', '', '', '', 1, 0, 'F', '0', 'admin', current_timestamp, '',
        current_timestamp, ''),
       ('1034', '参数导出', '106', '5', '#', '', '', '', 1, 0, 'F', '0', 'admin', current_timestamp, '',
        current_timestamp, ''),
-- 通知公告按钮
       ('1035', '公告查询', '107', '1', '#', '', '', '', 1, 0, 'F', '0', 'admin', current_timestamp, '',
        current_timestamp, ''),
       ('1036', '公告新增', '107', '2', '#', '', '', '', 1, 0, 'F', '0', 'admin', current_timestamp, '',
        current_timestamp, ''),
       ('1037', '公告修改', '107', '3', '#', '', '', '', 1, 0, 'F', '0', 'admin', current_timestamp, '',
        current_timestamp, ''),
       ('1038', '公告删除', '107', '4', '#', '', '', '', 1, 0, 'F', '0', 'admin', current_timestamp, '',
        current_timestamp, ''),
-- 操作日志按钮
       ('1039', '操作查询', '500', '1', '#', '', '', '', 1, 0, 'F', '0', 'admin', current_timestamp, '',
        current_timestamp, ''),
       ('1040', '操作删除', '500', '2', '#', '', '', '', 1, 0, 'F', '0', 'admin', current_timestamp, '',
        current_timestamp, ''),
       ('1041', '日志导出', '500', '3', '#', '', '', '', 1, 0, 'F', '0', 'admin', current_timestamp, '',
        current_timestamp, ''),
-- 登录日志按钮
       ('1042', '登录查询', '501', '1', '#', '', '', '', 1, 0, 'F', '0', 'admin', current_timestamp, '',
        current_timestamp, ''),
       ('1043', '登录删除', '501', '2', '#', '', '', '', 1, 0, 'F', '0', 'admin', current_timestamp, '',
        current_timestamp, ''),
       ('1044', '日志导出', '501', '3', '#', '', '', '', 1, 0, 'F', '0', 'admin', current_timestamp, '',
        current_timestamp, ''),
       ('1045', '账户解锁', '501', '4', '#', '', '', '', 1, 0, 'F', '0', 'admin', current_timestamp, '',
        current_timestamp, ''),
-- 在线用户按钮
       ('1046', '在线查询', '109', '1', '#', '', '', '', 1, 0, 'F', '0', 'admin', current_timestamp, '',
        current_timestamp, ''),
       ('1047', '批量强退', '109', '2', '#', '', '', '', 1, 0, 'F', '0', 'admin', current_timestamp, '',
        current_timestamp, '');
insert into sys_menu (menu_id, menu_name, parent_id, order_num, perms, url, target, icon, visible, status, is_cache,
                      del_flag, create_by, create_time, update_by, update_time, remarks)
values ('1048', '单条强退', '109', '3', '#', '', '', '', 1, 0, 'F', '0', '0', 'monitor:online:forceLogout', '#',
        'admin', CURRENT_TIMESTAMP, '', null, ''),
       ('1049', '任务查询', '110', '1', '#', '', '', '', 1, 0, 'F', '0', '0', 'monitor:job:query', '#', 'admin',
        CURRENT_TIMESTAMP, '', null, ''),
       ('1050', '任务新增', '110', '2', '#', '', '', '', 1, 0, 'F', '0', '0', 'monitor:job:add', '#', 'admin',
        CURRENT_TIMESTAMP, '', null, ''),
       ('1051', '任务修改', '110', '3', '#', '', '', '', 1, 0, 'F', '0', '0', 'monitor:job:edit', '#', 'admin',
        CURRENT_TIMESTAMP, '', null, ''),
       ('1052', '任务删除', '110', '4', '#', '', '', '', 1, 0, 'F', '0', '0', 'monitor:job:remove', '#', 'admin',
        CURRENT_TIMESTAMP, '', null, ''),
       ('1053', '状态修改', '110', '5', '#', '', '', '', 1, 0, 'F', '0', '0', 'monitor:job:changeStatus', '#', 'admin',
        CURRENT_TIMESTAMP, '', null, ''),
       ('1054', '任务导出', '110', '6', '#', '', '', '', 1, 0, 'F', '0', '0', 'monitor:job:export', '#', 'admin',
        CURRENT_TIMESTAMP, '', null, ''),
       ('1055', '生成查询', '116', '1', '#', '', '', '', 1, 0, 'F', '0', '0', 'tool:gen:query', '#', 'admin',
        CURRENT_TIMESTAMP, '', null, ''),
       ('1056', '生成修改', '116', '2', '#', '', '', '', 1, 0, 'F', '0', '0', 'tool:gen:edit', '#', 'admin',
        CURRENT_TIMESTAMP, '', null, ''),
       ('1057', '生成删除', '116', '3', '#', '', '', '', 1, 0, 'F', '0', '0', 'tool:gen:remove', '#', 'admin',
        CURRENT_TIMESTAMP, '', null, ''),
       ('1058', '导入代码', '116', '4', '#', '', '', '', 1, 0, 'F', '0', '0', 'tool:gen:import', '#', 'admin',
        CURRENT_TIMESTAMP, '', null, ''),
       ('1059', '预览代码', '116', '5', '#', '', '', '', 1, 0, 'F', '0', '0', 'tool:gen:preview', '#', 'admin',
        CURRENT_TIMESTAMP, '', null, ''),
       ('1060', '生成代码', '116', '6', '#', '', '', '', 1, 0, 'F', '0', '0', 'tool:gen:code', '#', 'admin',
        CURRENT_TIMESTAMP, '', null, '');

















