MyBatis实现递归获得树形结构的数据(1,菜单树,2,组织树)

场景优化:(1)递归菜单树结果放到缓存(redis)中,进入页面时直接展示:

MyBatis实现递归获得树形结构的数据(1,菜单树,2,组织树)_第1张图片

如上图:展示这样的目录树或者菜单树或者组织树等场景(测试的表结构)

SET FOREIGN_KEY_CHECKS=0;

-- ----------------------------
-- Table structure for upms_permission
-- ----------------------------
DROP TABLE IF EXISTS `upms_permission`;
CREATE TABLE `upms_permission` (
  `permission_id` bigint(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '编号',
  `system_id` int(10) unsigned NOT NULL COMMENT '所属系统',
  `parent_id` int(10) DEFAULT NULL COMMENT '所属上级',
  `menu_name` varchar(20) DEFAULT NULL COMMENT '名称',
  `type` tinyint(4) DEFAULT NULL COMMENT '类型(1:菜单,2:按钮)',
  `permission_name` varchar(50) DEFAULT NULL COMMENT '权限值',
  `path_url` varchar(100) DEFAULT NULL COMMENT '路径',
  `menu_level` int(1) DEFAULT '1' COMMENT '菜单等级',
  `icon_name` varchar(50) DEFAULT NULL COMMENT '图标',
  `status` tinyint(4) DEFAULT '1' COMMENT '状态(0:禁止,1:正常)',
  `create_time` timestamp(6) NULL DEFAULT NULL COMMENT '创建时间',
  `update_time` datetime(6) DEFAULT NULL COMMENT '排序',
  `sort` int(20) DEFAULT NULL COMMENT '排序',
  PRIMARY KEY (`permission_id`)
) ENGINE=InnoDB AUTO_INCREMENT=120 DEFAULT CHARSET=utf8mb4 COMMENT='权限';

测试数据:

==========================================开始==============================

-- ----------------------------
-- Records of upms_permission
-- ----------------------------
INSERT INTO `upms_permission` VALUES ('1', '1', '0', '系统组织管理', '1', '', '', '1', 'zmdi zmdi-accounts-list', '1', '2019-01-14 19:52:13.000000', null, null);
INSERT INTO `upms_permission` VALUES ('2', '1', '1', '系统管理', '1', 'upms:system:read', '/manage/system/index', '1', '', '1', '2019-01-14 19:52:13.000000', null, null);
INSERT INTO `upms_permission` VALUES ('3', '1', '1', '组织管理', '1', 'upms:organization:read', '/manage/organization/index', '1', '', '1', '2020-07-11 22:12:18.476000', '2020-07-11 22:12:18.477000', '100');
INSERT INTO `upms_permission` VALUES ('4', '1', '0', '角色用户管理', '1', '', '', '1', 'zmdi zmdi-accounts', '1', '2019-01-14 19:52:13.000000', null, null);
INSERT INTO `upms_permission` VALUES ('5', '1', '4', '角色管理', '1', 'upms:role:read', '/manage/role/index', '1', '', '1', '2019-01-14 19:52:13.000000', null, null);
INSERT INTO `upms_permission` VALUES ('6', '1', '4', '用户管理', '1', 'upms:user:read', '/manage/user/index', '1', '', '1', '2019-01-14 19:52:13.000000', null, null);
INSERT INTO `upms_permission` VALUES ('7', '1', '0', '权限资源管理', '1', '', '', '1', 'zmdi zmdi-lock-outline', '1', '2019-01-14 19:52:13.000000', null, null);
INSERT INTO `upms_permission` VALUES ('12', '1', '0', '其他数据管理', '1', '', '', '1', 'zmdi zmdi-more', '1', '2020-07-11 19:06:25.370000', '2020-07-11 19:06:25.370000', '100');
INSERT INTO `upms_permission` VALUES ('14', '1', '12', '会话管理', '1', 'upms:session:read', '/manage/session/index', '1', '', '1', '2019-01-14 19:52:13.000000', null, null);
INSERT INTO `upms_permission` VALUES ('15', '1', '12', '日志记录', '1', 'upms:log:read', '/manage/log/index', '1', '', '1', '2019-01-14 19:52:13.000000', null, null);
INSERT INTO `upms_permission` VALUES ('17', '2', '0', '标签类目管理', '1', null, null, '1', 'zmdi zmdi-menu', '1', '2019-01-14 19:52:13.000000', null, null);
INSERT INTO `upms_permission` VALUES ('18', '2', '17', '标签管理', '1', 'cms:tag:read', '/manage/tag/index', '1', null, '1', '2019-01-14 19:52:13.000000', null, null);
INSERT INTO `upms_permission` VALUES ('19', '2', '17', '类目管理', '1', 'cms:category:read', '/manage/category/index', '1', null, '1', '2019-01-14 19:52:13.000000', null, null);
INSERT INTO `upms_permission` VALUES ('20', '2', '0', '文章评论管理', '1', null, null, '1', 'zmdi zmdi-collection-text', '1', '2019-01-14 19:52:13.000000', null, null);
INSERT INTO `upms_permission` VALUES ('21', '2', '20', '文章管理', '1', 'cms:article:read', '/manage/article/index', '1', null, '1', '2019-01-14 19:52:13.000000', null, null);
INSERT INTO `upms_permission` VALUES ('22', '2', '20', '回收管理', '1', 'cms:article:read', '/manage/article/recycle', '1', null, '1', '2019-01-14 19:52:13.000000', null, null);
INSERT INTO `upms_permission` VALUES ('24', '1', '2', '新增系统', '2', 'upms:system:create', '/manage/system/create', '1', 'zmdi zmdi-plus', '1', '2019-01-14 19:52:13.000000', null, null);
INSERT INTO `upms_permission` VALUES ('25', '1', '2', '编辑系统', '2', 'upms:system:update', '/manage/system/update', '1', 'zmdi zmdi-edit', '1', '2019-01-14 19:52:13.000000', null, null);
INSERT INTO `upms_permission` VALUES ('26', '1', '2', '删除系统', '2', 'upms:system:delete', '/manage/system/delete', '1', 'zmdi zmdi-close', '1', '2019-01-14 19:52:13.000000', null, null);
INSERT INTO `upms_permission` VALUES ('27', '1', '3', '新增组织', '2', 'upms:organization:create', '/manage/organization/create', '1', 'zmdi zmdi-plus', '1', '2019-01-14 19:52:13.000000', null, null);
INSERT INTO `upms_permission` VALUES ('28', '1', '3', '编辑组织', '2', 'upms:organization:update', '/manage/organization/update', '1', 'zmdi zmdi-edit', '1', '2019-01-14 19:52:13.000000', null, null);
INSERT INTO `upms_permission` VALUES ('29', '1', '3', '删除组织', '2', 'upms:organization:delete', '/manage/organization/delete', '1', 'zmdi zmdi-close', '1', '2019-01-14 19:52:13.000000', null, null);
INSERT INTO `upms_permission` VALUES ('30', '1', '6', '新增用户', '2', 'upms:user:create', '/manage/user/create', '1', 'zmdi zmdi-plus', '1', '2019-01-14 19:52:13.000000', null, null);
INSERT INTO `upms_permission` VALUES ('31', '1', '6', '编辑用户', '2', 'upms:user:update', '/manage/user/update', '1', 'zmdi zmdi-edit', '1', '2019-01-14 19:52:13.000000', null, null);
INSERT INTO `upms_permission` VALUES ('32', '1', '6', '删除用户', '2', 'upms:user:delete', '/manage/user/delete', '1', 'zmdi zmdi-close', '1', '2019-01-14 19:52:13.000000', null, null);
INSERT INTO `upms_permission` VALUES ('33', '1', '5', '新增角色', '2', 'upms:role:create', '/manage/role/create', '1', 'zmdi zmdi-plus', '1', '2019-01-14 19:52:13.000000', null, null);
INSERT INTO `upms_permission` VALUES ('34', '1', '5', '编辑角色', '2', 'upms:role:update', '/manage/role/update', '1', 'zmdi zmdi-edit', '1', '2019-01-14 19:52:13.000000', null, null);
INSERT INTO `upms_permission` VALUES ('35', '1', '5', '删除角色', '2', 'upms:role:delete', '/manage/role/delete', '1', 'zmdi zmdi-close', '1', '2019-01-14 19:52:13.000000', null, null);
INSERT INTO `upms_permission` VALUES ('36', '1', '39', '新增权限', '2', 'upms:permission:create', '/manage/permission/create', '1', 'zmdi zmdi-plus', '1', '2019-01-14 19:52:13.000000', null, null);
INSERT INTO `upms_permission` VALUES ('37', '1', '39', '编辑权限', '2', 'upms:permission:update', '/manage/permission/update', '1', 'zmdi zmdi-edit', '1', '2019-01-14 19:52:13.000000', null, null);
INSERT INTO `upms_permission` VALUES ('38', '1', '39', '删除权限', '2', 'upms:permission:delete', '/manage/permission/delete', '1', 'zmdi zmdi-close', '1', '2019-01-14 19:52:13.000000', null, null);
INSERT INTO `upms_permission` VALUES ('39', '1', '7', '权限管理', '1', 'upms:permission:read', '/admin/all', '1', null, '1', '2019-01-14 19:52:13.000000', null, null);
INSERT INTO `upms_permission` VALUES ('46', '1', '5', '角色权限', '2', 'upms:role:permission', '/manage/role/permission', '1', 'zmdi zmdi-key', '1', '2019-01-14 19:52:13.000000', null, null);
INSERT INTO `upms_permission` VALUES ('48', '1', '6', '用户组织', '2', 'upms:user:organization', '/manage/user/organization', '1', 'zmdi zmdi-accounts-list', '1', '2019-01-14 19:52:13.000000', null, null);
INSERT INTO `upms_permission` VALUES ('50', '1', '6', '用户角色', '2', 'upms:user:role', '/manage/user/role', '1', 'zmdi zmdi-accounts', '1', '2019-01-14 19:52:13.000000', null, null);
INSERT INTO `upms_permission` VALUES ('51', '1', '6', '用户权限', '2', 'upms:user:permission', '/manage/user/permission', '1', 'zmdi zmdi-key', '1', '2019-01-14 19:52:13.000000', null, null);
INSERT INTO `upms_permission` VALUES ('53', '1', '14', '强制退出', '2', 'upms:session:forceout', '/manage/session/forceout', '1', 'zmdi zmdi-run', '1', '2019-01-14 19:52:13.000000', null, null);
INSERT INTO `upms_permission` VALUES ('54', '2', '18', '新增标签', '2', 'cms:tag:create', '/manage/tag/create', '1', 'zmdi zmdi-plus', '1', '2019-01-14 19:52:13.000000', null, null);
INSERT INTO `upms_permission` VALUES ('55', '2', '18', '编辑标签', '2', 'cms:tag:update', 'zmdi zmdi-edit', '1', 'zmdi zmdi-widgets', '1', '2019-01-14 19:52:13.000000', null, null);
INSERT INTO `upms_permission` VALUES ('56', '2', '18', '删除标签', '2', 'cms:tag:delete', '/manage/tag/delete', '1', 'zmdi zmdi-close', '1', '2019-01-14 19:52:13.000000', null, null);
INSERT INTO `upms_permission` VALUES ('57', '1', '15', '删除权限', '2', 'upms:log:delete', '/manage/log/delete', '1', 'zmdi zmdi-close', '1', '2020-07-11 22:13:49.609000', '2020-07-11 22:13:49.609000', '100');
INSERT INTO `upms_permission` VALUES ('58', '2', '19', '编辑类目', '2', 'cms:category:update', '/manage/category/update', '1', 'zmdi zmdi-edit', '1', '2019-01-14 19:52:13.000000', null, null);
INSERT INTO `upms_permission` VALUES ('59', '2', '19', '删除类目', '2', 'cms:category:delete', '/manage/category/delete', '1', 'zmdi zmdi-close', '1', '2019-01-14 19:52:13.000000', null, null);
INSERT INTO `upms_permission` VALUES ('60', '2', '19', '新增类目', '2', 'cms:category:create', '/manage/category/create', '1', 'zmdi zmdi-plus', '1', '2019-01-14 19:52:13.000000', null, null);
INSERT INTO `upms_permission` VALUES ('61', '2', '0', '其他数据管理', '1', '', '', '1', 'zmdi zmdi-more', '1', '2019-01-14 19:52:13.000000', null, null);
INSERT INTO `upms_permission` VALUES ('62', '2', '20', '评论管理', '1', 'cms:comment:read', '/manage/comment/index', '1', '', '1', '2019-01-14 19:52:13.000000', null, null);
INSERT INTO `upms_permission` VALUES ('63', '2', '62', '删除评论', '2', 'cms:comment:delete', '/manage/comment/delete', '1', 'zmdi zmdi-close', '1', '2019-01-14 19:52:13.000000', null, null);
INSERT INTO `upms_permission` VALUES ('64', '2', '79', '单页管理', '1', 'cms:page:read', '/manage/page/index', '1', '', '1', '2019-01-14 19:52:13.000000', null, null);
INSERT INTO `upms_permission` VALUES ('65', '2', '64', '新增单页', '2', 'cms:page:create', '/manage/page/create', '1', 'zmdi zmdi-plus', '1', '2019-01-14 19:52:13.000000', null, null);
INSERT INTO `upms_permission` VALUES ('66', '2', '64', '编辑单页', '2', 'cms:page:update', '/manage/page/update', '1', 'zmdi zmdi-edit', '1', '2019-01-14 19:52:13.000000', null, null);
INSERT INTO `upms_permission` VALUES ('67', '2', '64', '删除单页', '2', 'cms:page:delete', '/manage/page/delete', '1', 'zmdi zmdi-close', '1', '2019-01-14 19:52:13.000000', null, null);
INSERT INTO `upms_permission` VALUES ('68', '2', '61', '菜单管理', '1', 'cms:menu:read', '/manage/menu/index', '1', 'zmdi zmdi-widgets', '1', '2019-01-14 19:52:13.000000', null, null);
INSERT INTO `upms_permission` VALUES ('69', '2', '68', '新增菜单', '2', 'cms:menu:create', '/manage/menu/create', '1', 'zmdi zmdi-plus', '1', '2019-01-14 19:52:13.000000', null, null);
INSERT INTO `upms_permission` VALUES ('70', '2', '68', '编辑菜单', '2', 'cms:menu:update', '/manage/menu/update', '1', 'zmdi zmdi-edit', '1', '2019-01-14 19:52:13.000000', null, null);
INSERT INTO `upms_permission` VALUES ('71', '2', '68', '删除菜单', '2', 'cms:menu:delete', '/manage/menu/delete', '1', 'zmdi zmdi-close', '1', '2019-01-14 19:52:13.000000', null, null);
INSERT INTO `upms_permission` VALUES ('72', '2', '61', '系统设置', '2', 'cms:setting:read', '/manage/setting/index', '1', 'zmdi zmdi-widgets', '1', '2019-01-14 19:52:13.000000', null, null);
INSERT INTO `upms_permission` VALUES ('73', '2', '72', '新增设置', '2', 'cms:setting:create', '/manage/setting/create', '1', 'zmdi zmdi-plus', '1', '2019-01-14 19:52:13.000000', null, null);
INSERT INTO `upms_permission` VALUES ('74', '2', '72', '编辑设置', '2', 'cms:setting:update', '/manage/setting/update', '1', 'zmdi zmdi-edit', '1', '2019-01-14 19:52:13.000000', null, null);
INSERT INTO `upms_permission` VALUES ('75', '2', '72', '删除设置', '2', 'cms:setting:delete', '/manage/setting/delete', '1', 'zmdi zmdi-close', '1', '2019-01-14 19:52:13.000000', null, null);
INSERT INTO `upms_permission` VALUES ('76', '2', '21', '新增文章', '2', 'cms:article:create', '/manage/article/create', '1', 'zmdi zmdi-plus', '1', '2019-01-14 19:52:13.000000', null, null);
INSERT INTO `upms_permission` VALUES ('77', '2', '21', '编辑文章', '2', 'cms:article:update', '/manage/article/update', '1', 'zmdi zmdi-edit', '1', '2019-01-14 19:52:13.000000', null, null);
INSERT INTO `upms_permission` VALUES ('78', '2', '21', '删除文章', '2', 'cms:article:delete', '/manage/article/delete', '1', 'zmdi zmdi-close', '1', '2019-01-14 19:52:13.000000', null, null);
INSERT INTO `upms_permission` VALUES ('79', '2', '0', '单页专题管理', '1', '', '', '1', 'zmdi zmdi-view-web', '1', '2019-01-14 19:52:13.000000', null, null);
INSERT INTO `upms_permission` VALUES ('80', '2', '79', '专题管理', '2', 'cms:topic:read', '/manage/topic/index', '1', 'zmdi zmdi-widgets', '1', '2019-01-14 19:52:13.000000', null, null);
INSERT INTO `upms_permission` VALUES ('81', '2', '80', '新增专题', '2', 'cms:topic:create', '/manage/topic/create', '1', 'zmdi zmdi-plus', '1', '2019-01-14 19:52:13.000000', null, null);
INSERT INTO `upms_permission` VALUES ('82', '2', '80', '编辑专题', '2', 'cms:topic:update', '/manage/topic/update', '1', 'zmdi zmdi-edit', '1', '2019-01-14 19:52:13.000000', null, null);
INSERT INTO `upms_permission` VALUES ('83', '2', '80', '删除专题', '2', 'cms:topic:delete', '/manage/topic/delete', '1', 'zmdi zmdi-close', '1', '2019-01-14 19:52:13.000000', null, null);
INSERT INTO `upms_permission` VALUES ('84', '2', '68', '上移菜单', '2', 'cms:menu:up', '/manage/menu/up', '1', 'zmdi zmdi-long-arrow-up', '1', '2019-01-14 19:52:13.000000', null, null);
INSERT INTO `upms_permission` VALUES ('85', '2', '68', '下移菜单', '2', 'cms:menu:down', '/manage/menu/down', '1', 'zmdi zmdi-long-arrow-down', '1', '2019-01-14 19:52:13.000000', null, null);
INSERT INTO `upms_permission` VALUES ('86', '1', '0', '消息管理', '1', null, '/manage/system/message', '1', 'zmdi zmdi-lock-outline', '1', '2020-07-11 19:06:29.713000', '2020-07-11 19:06:29.713000', '100');
INSERT INTO `upms_permission` VALUES ('87', '1', '86', '预警管理', '1', 'upms:system:read', '/manage/system/look', '1', null, '1', '2019-07-04 20:27:09.000000', null, null);
INSERT INTO `upms_permission` VALUES ('88', '1', '0', '炫酷特效', '1', null, '', '1', 'zmdi zmdi-widgets', '1', '2020-07-11 19:12:59.556000', '2020-07-11 19:12:59.556000', '100');
INSERT INTO `upms_permission` VALUES ('89', '1', '88', '特效桌面', '1', 'upms:desktop:read', '/manage/desktop/look', '1', null, '1', '2019-07-05 19:36:05.000000', null, null);
INSERT INTO `upms_permission` VALUES ('90', '1', '88', '天体旋转', '1', 'upms:desktop:look', '/manage/desktop/togosun', '1', null, '1', '2019-07-05 20:45:22.000000', null, null);
INSERT INTO `upms_permission` VALUES ('91', '1', '0', '工具管理', '1', null, null, '1', 'zmdi zmdi-key', '1', '2020-07-11 18:34:09.682000', '2020-07-11 18:34:09.682000', '100');
INSERT INTO `upms_permission` VALUES ('92', '1', '91', '动态表单', '1', 'upms:desktop:read', '/tools/desktop/read', '1', null, '1', '2019-07-05 21:34:32.000000', null, null);
INSERT INTO `upms_permission` VALUES ('93', '1', '88', '激光炫舞', '1', 'upms:desktop:read', '/manage/desktop/laserlook', '1', null, '1', '2019-07-05 22:04:14.000000', null, null);
INSERT INTO `upms_permission` VALUES ('94', '1', '88', '罗马时钟', '1', 'upms:desktop:look', '/manage/desktop/romelock', '1', null, '1', '2019-07-05 22:15:08.000000', null, null);
INSERT INTO `upms_permission` VALUES ('95', '1', '88', '背景变换11111', '1', 'upms:tools:change', '/tools/desktop/change', '1', 'fa-file-archive-o', '1', '2020-07-12 15:55:09.894000', '2020-07-12 15:55:09.894000', '100');
INSERT INTO `upms_permission` VALUES ('96', '1', '88', '粒子背景', '1', 'upms:desktop:look', '/manage/desktop/bg', '1', null, '1', '2019-07-05 23:40:59.000000', null, null);
INSERT INTO `upms_permission` VALUES ('97', '1', '88', '雷达扫描', '1', 'upms:desktop:read', '/manage/desktop/radar', '1', null, '1', '2019-07-06 00:18:28.000000', null, null);
INSERT INTO `upms_permission` VALUES ('98', '1', '88', '花瓣飞舞', '1', 'upms:desktop:look', '/manage/desktop/petals', '1', null, '1', '2019-07-06 00:31:06.000000', null, null);
INSERT INTO `upms_permission` VALUES ('99', '1', '88', '玄心图', '1', 'upms:desktop:read', '/manage/desktop/hedgehog', '1', null, '1', '2019-07-06 00:42:08.000000', null, null);
INSERT INTO `upms_permission` VALUES ('100', '1', '91', '在线客服', '1', 'upms:desktop:look', '/manage/tools/customerservice', '1', null, '1', '2019-07-06 01:13:37.000000', null, null);
INSERT INTO `upms_permission` VALUES ('101', '1', '88', '楷模精英', '1', 'upms:desktop:read', '/manage/desktop/gotoresumelist', '1', null, '1', '2019-07-06 01:44:24.000000', null, null);
INSERT INTO `upms_permission` VALUES ('102', '1', '88', '炫酷厅展', '1', 'upms:desktop:look', '/manage/desktop/readmodulelist', '1', null, '1', '2019-07-06 02:01:04.000000', null, null);
INSERT INTO `upms_permission` VALUES ('103', '1', '86', '提示预警', '1', 'upms:desktop:query', '/manage/desktop/msgWarnTips', '1', null, '1', '2019-07-06 02:25:15.000000', null, null);
INSERT INTO `upms_permission` VALUES ('104', '1', '91', '吐字机', '1', 'upms:desktop:writer', '/manage/tools/enunciationmachine', '1', null, '1', '2019-07-06 02:47:20.000000', null, null);
INSERT INTO `upms_permission` VALUES ('105', '1', '91', '自检机', '1', 'upms:desktop:check', '/manage/tools/autocheck', '1', null, '1', '2019-07-06 03:02:11.000000', null, null);
INSERT INTO `upms_permission` VALUES ('106', '1', '88', '矩阵数字雨', '1', 'upms:desktop:look', '/manage/desktop/matrixdigital', '1', null, '1', '2019-07-06 03:36:42.000000', null, null);
INSERT INTO `upms_permission` VALUES ('107', '1', '88', '汇流成河', '1', 'upms:desktop:read', '/manage/desktop/river', '1', null, '1', '2019-07-06 03:50:34.000000', null, null);
INSERT INTO `upms_permission` VALUES ('108', '1', '88', '熊熊焰火', '1', 'upms:desktop:look', '/manage/desktop/fireworks', '1', null, '1', '2019-07-06 04:00:19.000000', null, null);
INSERT INTO `upms_permission` VALUES ('109', '1', '0', '监控管理', '1', null, null, '1', 'zmdi zmdi-lock-outline', '1', '2020-07-11 18:34:07.018000', '2020-07-11 18:34:07.019000', '100');
INSERT INTO `upms_permission` VALUES ('110', '1', '109', '晋城运输监控', '1', 'upms:tools:look', '/manage/tools/realTimemonitor', '1', null, '1', '2019-07-06 15:41:19.000000', null, null);
INSERT INTO `upms_permission` VALUES ('111', '1', '91', '许愿墙', '1', 'upms:tools:read', '/manage/tools/wishingwall', '1', null, '1', '2019-07-06 22:08:47.000000', null, null);
INSERT INTO `upms_permission` VALUES ('112', '1', '91', '防控3D预警', '1', 'upms:tools:create', '/manage/tools/d3effects', '1', null, '1', '2019-07-06 22:41:45.000000', null, null);
INSERT INTO `upms_permission` VALUES ('113', '1', '91', '网络架子鼓', '1', 'upms:tools:look', '/manage/tools/networkDrumSet', '1', null, '1', '2019-07-08 20:19:06.000000', null, null);
INSERT INTO `upms_permission` VALUES ('114', '1', '91', '网络钢琴', '1', 'upms:tools:look', '/manage/tools/networkPiano', '1', null, '1', '2019-07-08 20:58:01.000000', null, null);
INSERT INTO `upms_permission` VALUES ('115', '1', '91', '碎片相册', '1', 'upms:tools:look', '/manage/tools/fragmentaryAlbum', '1', null, '1', '2019-07-08 21:34:52.000000', null, null);
INSERT INTO `upms_permission` VALUES ('116', '1', '91', '图像标注特效', '1', 'upms:tools:read', '/manage/tools/annotationEffect', '1', null, '1', '2019-07-08 21:50:34.000000', null, null);
INSERT INTO `upms_permission` VALUES ('117', '1', '88', '蜘蛛织网', '1', 'upms:desktop:look', '/manage/desktop/spiderweb', '1', null, '1', '2019-07-09 19:53:20.000000', null, null);
INSERT INTO `upms_permission` VALUES ('118', '1', '88', '逼真烟花', '1', 'upms:desktop:read', '/manage/desktop/realisticFireworks', '1', null, '1', '2019-07-09 20:15:23.000000', null, null);
INSERT INTO `upms_permission` VALUES ('119', '1', '109', '设备管理', '1', 'upms:device:read', '/manage/device/index', '1', null, '1', '2019-10-26 10:01:46.000000', null, null);

映射的实体类:

package org.jy.sso.cas.data.monitor.ui.domain;
import com.alibaba.fastjson.annotation.JSONField;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
@Data
@TableName(value = "upms_permission")
public class UpmnPermission implements Serializable{
    private static final long serialVersionUID = 6180869216498363919L;
    @TableId(value = "permission_id",type = IdType.AUTO) // 自增长策略
    private Long permissionId;
    private Integer systemId=1;
    private Long parentId;// 菜单父ID
    @TableField(exist = false)
    private String parentIdAndLevel;// 复合字段:parentId与menuLevel 组合
    private Integer menuLevel;// 菜单等级
    private String menuName;
    @TableField("icon_name")
    private String cssName;  // 数据库驼峰会自动识别
    private String pathUrl;
    private Integer type = PermissionTypeEnum.PermissionMenu; // 避免前端不现在(默认值)
    private String permissionName; // 权限字符串
    @TableField(exist = false)
    private String permission;  // 某个用户的所有的权限字符串
    private Integer  status = PermissionStatusEnum.statusEnable;  // 状态(0:禁止,1:正常)
    private Integer sort=100;  // 排序
    //设置时区为上海时区,时间格式自己据需求定。
    @JSONField(format= "yyyy-MM-dd HH:mm:ss")
    private Date createTime = new Date();
    //设置时区为上海时区,时间格式自己据需求定。
    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private Date updateTime = new Date();
    @TableField(exist = false) // 表示该属性不为数据库表字段,但又是必须使用的。
    private List child; //  子权限


    public interface PermissionStatusEnum { // 菜单使用状况
        int statusDiable = 0; // 禁用
        int statusEnable = 1;  // 启用
    }
    public interface PermissionTypeEnum {  // 权限类型
        int PermissionMenu = 0;  // 菜单
        int PermissionButtom= 1; // 按钮
    }


}

MyBatis注解代码:

注意:使用该方法,可以原理上可以无限多久,但数据量大时,严重影响性能,所有提倡使用缓存,每次从缓存中获取

    /**
     * 查询菜单树
     * @param systemId
     * @return
     */
    @Select("select * from upms_permission where parent_id = 0 and system_id = #{systemId}")
    @Results(id="upmn_permission_tree",value = { // 结果集的映射
            @Result(id=true,column = "permission_id",property = "permissionId",javaType=Long.class),
            @Result(column = "system_id",property = "systemId"),
            @Result(column = "parent_id",property = "parentId"),
            @Result(column = "menu_level",property = "menuLevel"),
            @Result(column = "menu_name",property = "menuName"),
            @Result(column = "icon_name",property = "cssName"),
            @Result(column = "path_url",property = "pathUrl"),
            @Result(column = "type",property = "type"),
            @Result(column = "permission_name",property = "permissionName"),
            @Result(column = "status",property = "status"),
            @Result(column = "sort",property = "sort"),
            @Result(column = "create_time",property = "createTime"),
            @Result(column = "update_time",property = "updateTime"),
            @Result(column = "permission_id",property = "child",many = @Many(select = "org.jy.sso.cas.data.monitor.ui.mapper.UpmnPermissionMapper.getTreeByParentId",fetchType= FetchType.EAGER))
    })
    List getTreeList(@Param("systemId")String systemId);

    @Select("select * from upms_permission where parent_id = #{permissionId}")
    @ResultMap("upmn_permission_tree")
    List getTreeByParentId(int permissionId);

测试输出结果:

UpmnPermission(permissionId=1, systemId=1, parentId=0, parentIdAndLevel=null, menuLevel=1, menuName=系统组织管理, cssName=zmdi zmdi-accounts-list, pathUrl=, type=1, permissionName=, permission=null, status=1, sort=100, createTime=Mon Jan 14 19:52:13 CST 2019, updateTime=Mon Jul 13 12:59:46 CST 2020, child=[UpmnPermission(permissionId=2, systemId=1, parentId=1, parentIdAndLevel=null, menuLevel=1, menuName=系统管理, cssName=, pathUrl=/manage/system/index, type=1, permissionName=upms:system:read, permission=null, status=1, sort=100, createTime=Mon Jan 14 19:52:13 CST 2019, updateTime=Mon Jul 13 12:59:46 CST 2020, child=[UpmnPermission(permissionId=24, systemId=1, parentId=2, parentIdAndLevel=null, menuLevel=1, menuName=新增系统, cssName=zmdi zmdi-plus, pathUrl=/manage/system/create, type=2, permissionName=upms:system:create, permission=null, status=1, sort=100, createTime=Mon Jan 14 19:52:13 CST 2019, updateTime=Mon Jul 13 12:59:46 CST 2020, child=[]), UpmnPermission(permissionId=25, systemId=1, parentId=2, parentIdAndLevel=null, menuLevel=1, menuName=编辑系统, cssName=zmdi zmdi-edit, pathUrl=/manage/system/update, type=2, permissionName=upms:system:update, permission=null, status=1, sort=100, createTime=Mon Jan 14 19:52:13 CST 2019, updateTime=Mon Jul 13 12:59:46 CST 2020, child=[]), UpmnPermission(permissionId=26, systemId=1, parentId=2, parentIdAndLevel=null, menuLevel=1, menuName=删除系统, cssName=zmdi zmdi-close, pathUrl=/manage/system/delete, type=2, permissionName=upms:system:delete, permission=null, status=1, sort=100, createTime=Mon Jan 14 19:52:13 CST 2019, updateTime=Mon Jul 13 12:59:46 CST 2020, child=[])]), UpmnPermission(permissionId=3, systemId=1, parentId=1, parentIdAndLevel=null, menuLevel=1, menuName=组织管理, cssName=, pathUrl=/manage/organization/index, type=1, permissionName=upms:organization:read, permission=null, status=1, sort=100, createTime=Sat Jul 11 22:12:18 CST 2020, updateTime=Sat Jul 11 22:12:18 CST 2020, child=[UpmnPermission(permissionId=27, systemId=1, parentId=3, parentIdAndLevel=null, menuLevel=1, menuName=新增组织, cssName=zmdi zmdi-plus, pathUrl=/manage/organization/create, type=2, permissionName=upms:organization:create, permission=null, status=1, sort=100, createTime=Mon Jan 14 19:52:13 CST 2019, updateTime=Mon Jul 13 12:59:46 CST 2020, child=[]), UpmnPermission(permissionId=28, systemId=1, parentId=3, parentIdAndLevel=null, menuLevel=1, menuName=编辑组织, cssName=zmdi zmdi-edit, pathUrl=/manage/organization/update, type=2, permissionName=upms:organization:update, permission=null, status=1, sort=100, createTime=Mon Jan 14 19:52:13 CST 2019, updateTime=Mon Jul 13 12:59:46 CST 2020, child=[]), UpmnPermission(permissionId=29, systemId=1, parentId=3, parentIdAndLevel=null, menuLevel=1, menuName=删除组织, cssName=zmdi zmdi-close, pathUrl=/manage/organization/delete, type=2, permissionName=upms:organization:delete, permission=null, status=1, sort=100, createTime=Mon Jan 14 19:52:13 CST 2019, updateTime=Mon Jul 13 12:59:46 CST 2020, child=[])])])
UpmnPermission(permissionId=4, systemId=1, parentId=0, parentIdAndLevel=null, menuLevel=1, menuName=角色用户管理, cssName=zmdi zmdi-accounts, pathUrl=, type=1, permissionName=, permission=null, status=1, sort=100, createTime=Mon Jan 14 19:52:13 CST 2019, updateTime=Mon Jul 13 12:59:46 CST 2020, child=[UpmnPermission(permissionId=5, systemId=1, parentId=4, parentIdAndLevel=null, menuLevel=1, menuName=角色管理, cssName=, pathUrl=/manage/role/index, type=1, permissionName=upms:role:read, permission=null, status=1, sort=100, createTime=Mon Jan 14 19:52:13 CST 2019, updateTime=Mon Jul 13 12:59:46 CST 2020, child=[UpmnPermission(permissionId=33, systemId=1, parentId=5, parentIdAndLevel=null, menuLevel=1, menuName=新增角色, cssName=zmdi zmdi-plus, pathUrl=/manage/role/create, type=2, permissionName=upms:role:create, permission=null, status=1, sort=100, createTime=Mon Jan 14 19:52:13 CST 2019, updateTime=Mon Jul 13 12:59:46 CST 2020, child=[]), UpmnPermission(permissionId=34, systemId=1, parentId=5, parentIdAndLevel=null, menuLevel=1, menuName=编辑角色, cssName=zmdi zmdi-edit, pathUrl=/manage/role/update, type=2, permissionName=upms:role:update, permission=null, status=1, sort=100, createTime=Mon Jan 14 19:52:13 CST 2019, updateTime=Mon Jul 13 12:59:46 CST 2020, child=[]), UpmnPermission(permissionId=35, systemId=1, parentId=5, parentIdAndLevel=null, menuLevel=1, menuName=删除角色, cssName=zmdi zmdi-close, pathUrl=/manage/role/delete, type=2, permissionName=upms:role:delete, permission=null, status=1, sort=100, createTime=Mon Jan 14 19:52:13 CST 2019, updateTime=Mon Jul 13 12:59:46 CST 2020, child=[]), UpmnPermission(permissionId=46, systemId=1, parentId=5, parentIdAndLevel=null, menuLevel=1, menuName=角色权限, cssName=zmdi zmdi-key, pathUrl=/manage/role/permission, type=2, permissionName=upms:role:permission, permission=null, status=1, sort=100, createTime=Mon Jan 14 19:52:13 CST 2019, updateTime=Mon Jul 13 12:59:46 CST 2020, child=[])]), UpmnPermission(permissionId=6, systemId=1, parentId=4, parentIdAndLevel=null, menuLevel=1, menuName=用户管理, cssName=, pathUrl=/manage/user/index, type=1, permissionName=upms:user:read, permission=null, status=1, sort=100, createTime=Mon Jan 14 19:52:13 CST 2019, updateTime=Mon Jul 13 12:59:46 CST 2020, child=[UpmnPermission(permissionId=30, systemId=1, parentId=6, parentIdAndLevel=null, menuLevel=1, menuName=新增用户, cssName=zmdi zmdi-plus, pathUrl=/manage/user/create, type=2, permissionName=upms:user:create, permission=null, status=1, sort=100, createTime=Mon Jan 14 19:52:13 CST 2019, updateTime=Mon Jul 13 12:59:46 CST 2020, child=[]), UpmnPermission(permissionId=31, systemId=1, parentId=6, parentIdAndLevel=null, menuLevel=1, menuName=编辑用户, cssName=zmdi zmdi-edit, pathUrl=/manage/user/update, type=2, permissionName=upms:user:update, permission=null, status=1, sort=100, createTime=Mon Jan 14 19:52:13 CST 2019, updateTime=Mon Jul 13 12:59:46 CST 2020, child=[]), UpmnPermission(permissionId=32, systemId=1, parentId=6, parentIdAndLevel=null, menuLevel=1, menuName=删除用户, cssName=zmdi zmdi-close, pathUrl=/manage/user/delete, type=2, permissionName=upms:user:delete, permission=null, status=1, sort=100, createTime=Mon Jan 14 19:52:13 CST 2019, updateTime=Mon Jul 13 12:59:46 CST 2020, child=[]), UpmnPermission(permissionId=48, systemId=1, parentId=6, parentIdAndLevel=null, menuLevel=1, menuName=用户组织, cssName=zmdi zmdi-accounts-list, pathUrl=/manage/user/organization, type=2, permissionName=upms:user:organization, permission=null, status=1, sort=100, createTime=Mon Jan 14 19:52:13 CST 2019, updateTime=Mon Jul 13 12:59:46 CST 2020, child=[]), UpmnPermission(permissionId=50, systemId=1, parentId=6, parentIdAndLevel=null, menuLevel=1, menuName=用户角色, cssName=zmdi zmdi-accounts, pathUrl=/manage/user/role, type=2, permissionName=upms:user:role, permission=null, status=1, sort=100, createTime=Mon Jan 14 19:52:13 CST 2019, updateTime=Mon Jul 13 12:59:46 CST 2020, child=[]), UpmnPermission(permissionId=51, systemId=1, parentId=6, parentIdAndLevel=null, menuLevel=1, menuName=用户权限, cssName=zmdi zmdi-key, pathUrl=/manage/user/permission, type=2, permissionName=upms:user:permission, permission=null, status=1, sort=100, createTime=Mon Jan 14 19:52:13 CST 2019, updateTime=Mon Jul 13 12:59:46 CST 2020, child=[])])])
UpmnPermission(permissionId=7, systemId=1, parentId=0, parentIdAndLevel=null, menuLevel=1, menuName=权限资源管理, cssName=zmdi zmdi-lock-outline, pathUrl=, type=1, permissionName=, permission=null, status=1, sort=100, createTime=Mon Jan 14 19:52:13 CST 2019, updateTime=Mon Jul 13 12:59:46 CST 2020, child=[UpmnPermission(permissionId=39, systemId=1, parentId=7, parentIdAndLevel=null, menuLevel=1, menuName=权限管理, cssName=null, pathUrl=/admin/all, type=1, permissionName=upms:permission:read, permission=null, status=1, sort=100, createTime=Mon Jan 14 19:52:13 CST 2019, updateTime=Mon Jul 13 12:59:46 CST 2020, child=[UpmnPermission(permissionId=36, systemId=1, parentId=39, parentIdAndLevel=null, menuLevel=1, menuName=新增权限, cssName=zmdi zmdi-plus, pathUrl=/manage/permission/create, type=2, permissionName=upms:permission:create, permission=null, status=1, sort=100, createTime=Mon Jan 14 19:52:13 CST 2019, updateTime=Mon Jul 13 12:59:46 CST 2020, child=[]), UpmnPermission(permissionId=37, systemId=1, parentId=39, parentIdAndLevel=null, menuLevel=1, menuName=编辑权限, cssName=zmdi zmdi-edit, pathUrl=/manage/permission/update, type=2, permissionName=upms:permission:update, permission=null, status=1, sort=100, createTime=Mon Jan 14 19:52:13 CST 2019, updateTime=Mon Jul 13 12:59:46 CST 2020, child=[]), UpmnPermission(permissionId=38, systemId=1, parentId=39, parentIdAndLevel=null, menuLevel=1, menuName=删除权限, cssName=zmdi zmdi-close, pathUrl=/manage/permission/delete, type=2, permissionName=upms:permission:delete, permission=null, status=1, sort=100, createTime=Mon Jan 14 19:52:13 CST 2019, updateTime=Mon Jul 13 12:59:46 CST 2020, child=[])])])
UpmnPermission(permissionId=12, systemId=1, parentId=0, parentIdAndLevel=null, menuLevel=1, menuName=其他数据管理, cssName=zmdi zmdi-more, pathUrl=, type=1, permissionName=, permission=null, status=1, sort=100, createTime=Sat Jul 11 19:06:25 CST 2020, updateTime=Sat Jul 11 19:06:25 CST 2020, child=[UpmnPermission(permissionId=14, systemId=1, parentId=12, parentIdAndLevel=null, menuLevel=1, menuName=会话管理, cssName=, pathUrl=/manage/session/index, type=1, permissionName=upms:session:read, permission=null, status=1, sort=100, createTime=Mon Jan 14 19:52:13 CST 2019, updateTime=Mon Jul 13 12:59:46 CST 2020, child=[UpmnPermission(permissionId=53, systemId=1, parentId=14, parentIdAndLevel=null, menuLevel=1, menuName=强制退出, cssName=zmdi zmdi-run, pathUrl=/manage/session/forceout, type=2, permissionName=upms:session:forceout, permission=null, status=1, sort=100, createTime=Mon Jan 14 19:52:13 CST 2019, updateTime=Mon Jul 13 12:59:46 CST 2020, child=[])]), UpmnPermission(permissionId=15, systemId=1, parentId=12, parentIdAndLevel=null, menuLevel=1, menuName=日志记录, cssName=, pathUrl=/manage/log/index, type=1, permissionName=upms:log:read, permission=null, status=1, sort=100, createTime=Mon Jan 14 19:52:13 CST 2019, updateTime=Mon Jul 13 12:59:46 CST 2020, child=[UpmnPermission(permissionId=57, systemId=1, parentId=15, parentIdAndLevel=null, menuLevel=1, menuName=删除权限, cssName=zmdi zmdi-close, pathUrl=/manage/log/delete, type=2, permissionName=upms:log:delete, permission=null, status=1, sort=100, createTime=Sat Jul 11 22:13:49 CST 2020, updateTime=Sat Jul 11 22:13:49 CST 2020, child=[])])])
UpmnPermission(permissionId=86, systemId=1, parentId=0, parentIdAndLevel=null, menuLevel=1, menuName=消息管理, cssName=zmdi zmdi-lock-outline, pathUrl=/manage/system/message, type=1, permissionName=null, permission=null, status=1, sort=100, createTime=Sat Jul 11 19:06:29 CST 2020, updateTime=Sat Jul 11 19:06:29 CST 2020, child=[UpmnPermission(permissionId=87, systemId=1, parentId=86, parentIdAndLevel=null, menuLevel=1, menuName=预警管理, cssName=null, pathUrl=/manage/system/look, type=1, permissionName=upms:system:read, permission=null, status=1, sort=100, createTime=Thu Jul 04 20:27:09 CST 2019, updateTime=Mon Jul 13 12:59:46 CST 2020, child=[]), UpmnPermission(permissionId=103, systemId=1, parentId=86, parentIdAndLevel=null, menuLevel=1, menuName=提示预警, cssName=null, pathUrl=/manage/desktop/msgWarnTips, type=1, permissionName=upms:desktop:query, permission=null, status=1, sort=100, createTime=Sat Jul 06 02:25:15 CST 2019, updateTime=Mon Jul 13 12:59:46 CST 2020, child=[])])
UpmnPermission(permissionId=88, systemId=1, parentId=0, parentIdAndLevel=null, menuLevel=1, menuName=炫酷特效, cssName=zmdi zmdi-widgets, pathUrl=, type=1, permissionName=null, permission=null, status=1, sort=100, createTime=Sat Jul 11 19:12:59 CST 2020, updateTime=Sat Jul 11 19:12:59 CST 2020, child=[UpmnPermission(permissionId=89, systemId=1, parentId=88, parentIdAndLevel=null, menuLevel=1, menuName=特效桌面, cssName=null, pathUrl=/manage/desktop/look, type=1, permissionName=upms:desktop:read, permission=null, status=1, sort=100, createTime=Fri Jul 05 19:36:05 CST 2019, updateTime=Mon Jul 13 12:59:46 CST 2020, child=[]), UpmnPermission(permissionId=90, systemId=1, parentId=88, parentIdAndLevel=null, menuLevel=1, menuName=天体旋转, cssName=null, pathUrl=/manage/desktop/togosun, type=1, permissionName=upms:desktop:look, permission=null, status=1, sort=100, createTime=Fri Jul 05 20:45:22 CST 2019, updateTime=Mon Jul 13 12:59:46 CST 2020, child=[]), UpmnPermission(permissionId=93, systemId=1, parentId=88, parentIdAndLevel=null, menuLevel=1, menuName=激光炫舞, cssName=null, pathUrl=/manage/desktop/laserlook, type=1, permissionName=upms:desktop:read, permission=null, status=1, sort=100, createTime=Fri Jul 05 22:04:14 CST 2019, updateTime=Mon Jul 13 12:59:46 CST 2020, child=[]), UpmnPermission(permissionId=94, systemId=1, parentId=88, parentIdAndLevel=null, menuLevel=1, menuName=罗马时钟, cssName=null, pathUrl=/manage/desktop/romelock, type=1, permissionName=upms:desktop:look, permission=null, status=1, sort=100, createTime=Fri Jul 05 22:15:08 CST 2019, updateTime=Mon Jul 13 12:59:46 CST 2020, child=[]), UpmnPermission(permissionId=95, systemId=1, parentId=88, parentIdAndLevel=null, menuLevel=1, menuName=背景变换11111, cssName=fa-file-archive-o, pathUrl=/tools/desktop/change, type=1, permissionName=upms:tools:change, permission=null, status=1, sort=100, createTime=Sun Jul 12 15:55:09 CST 2020, updateTime=Sun Jul 12 15:55:09 CST 2020, child=[]), UpmnPermission(permissionId=96, systemId=1, parentId=88, parentIdAndLevel=null, menuLevel=1, menuName=粒子背景, cssName=null, pathUrl=/manage/desktop/bg, type=1, permissionName=upms:desktop:look, permission=null, status=1, sort=100, createTime=Fri Jul 05 23:40:59 CST 2019, updateTime=Mon Jul 13 12:59:46 CST 2020, child=[]), UpmnPermission(permissionId=97, systemId=1, parentId=88, parentIdAndLevel=null, menuLevel=1, menuName=雷达扫描, cssName=null, pathUrl=/manage/desktop/radar, type=1, permissionName=upms:desktop:read, permission=null, status=1, sort=100, createTime=Sat Jul 06 00:18:28 CST 2019, updateTime=Mon Jul 13 12:59:46 CST 2020, child=[]), UpmnPermission(permissionId=98, systemId=1, parentId=88, parentIdAndLevel=null, menuLevel=1, menuName=花瓣飞舞, cssName=null, pathUrl=/manage/desktop/petals, type=1, permissionName=upms:desktop:look, permission=null, status=1, sort=100, createTime=Sat Jul 06 00:31:06 CST 2019, updateTime=Mon Jul 13 12:59:46 CST 2020, child=[]), UpmnPermission(permissionId=99, systemId=1, parentId=88, parentIdAndLevel=null, menuLevel=1, menuName=玄心图, cssName=null, pathUrl=/manage/desktop/hedgehog, type=1, permissionName=upms:desktop:read, permission=null, status=1, sort=100, createTime=Sat Jul 06 00:42:08 CST 2019, updateTime=Mon Jul 13 12:59:46 CST 2020, child=[]), UpmnPermission(permissionId=101, systemId=1, parentId=88, parentIdAndLevel=null, menuLevel=1, menuName=楷模精英, cssName=null, pathUrl=/manage/desktop/gotoresumelist, type=1, permissionName=upms:desktop:read, permission=null, status=1, sort=100, createTime=Sat Jul 06 01:44:24 CST 2019, updateTime=Mon Jul 13 12:59:46 CST 2020, child=[]), UpmnPermission(permissionId=102, systemId=1, parentId=88, parentIdAndLevel=null, menuLevel=1, menuName=炫酷厅展, cssName=null, pathUrl=/manage/desktop/readmodulelist, type=1, permissionName=upms:desktop:look, permission=null, status=1, sort=100, createTime=Sat Jul 06 02:01:04 CST 2019, updateTime=Mon Jul 13 12:59:46 CST 2020, child=[]), UpmnPermission(permissionId=106, systemId=1, parentId=88, parentIdAndLevel=null, menuLevel=1, menuName=矩阵数字雨, cssName=null, pathUrl=/manage/desktop/matrixdigital, type=1, permissionName=upms:desktop:look, permission=null, status=1, sort=100, createTime=Sat Jul 06 03:36:42 CST 2019, updateTime=Mon Jul 13 12:59:46 CST 2020, child=[]), UpmnPermission(permissionId=107, systemId=1, parentId=88, parentIdAndLevel=null, menuLevel=1, menuName=汇流成河, cssName=null, pathUrl=/manage/desktop/river, type=1, permissionName=upms:desktop:read, permission=null, status=1, sort=100, createTime=Sat Jul 06 03:50:34 CST 2019, updateTime=Mon Jul 13 12:59:46 CST 2020, child=[]), UpmnPermission(permissionId=108, systemId=1, parentId=88, parentIdAndLevel=null, menuLevel=1, menuName=熊熊焰火, cssName=null, pathUrl=/manage/desktop/fireworks, type=1, permissionName=upms:desktop:look, permission=null, status=1, sort=100, createTime=Sat Jul 06 04:00:19 CST 2019, updateTime=Mon Jul 13 12:59:46 CST 2020, child=[]), UpmnPermission(permissionId=117, systemId=1, parentId=88, parentIdAndLevel=null, menuLevel=1, menuName=蜘蛛织网, cssName=null, pathUrl=/manage/desktop/spiderweb, type=1, permissionName=upms:desktop:look, permission=null, status=1, sort=100, createTime=Tue Jul 09 19:53:20 CST 2019, updateTime=Mon Jul 13 12:59:46 CST 2020, child=[]), UpmnPermission(permissionId=118, systemId=1, parentId=88, parentIdAndLevel=null, menuLevel=1, menuName=逼真烟花, cssName=null, pathUrl=/manage/desktop/realisticFireworks, type=1, permissionName=upms:desktop:read, permission=null, status=1, sort=100, createTime=Tue Jul 09 20:15:23 CST 2019, updateTime=Mon Jul 13 12:59:46 CST 2020, child=[])])
UpmnPermission(permissionId=91, systemId=1, parentId=0, parentIdAndLevel=null, menuLevel=1, menuName=工具管理, cssName=zmdi zmdi-key, pathUrl=null, type=1, permissionName=null, permission=null, status=1, sort=100, createTime=Sat Jul 11 18:34:09 CST 2020, updateTime=Sat Jul 11 18:34:09 CST 2020, child=[UpmnPermission(permissionId=92, systemId=1, parentId=91, parentIdAndLevel=null, menuLevel=1, menuName=动态表单, cssName=null, pathUrl=/tools/desktop/read, type=1, permissionName=upms:desktop:read, permission=null, status=1, sort=100, createTime=Fri Jul 05 21:34:32 CST 2019, updateTime=Mon Jul 13 12:59:46 CST 2020, child=[]), UpmnPermission(permissionId=100, systemId=1, parentId=91, parentIdAndLevel=null, menuLevel=1, menuName=在线客服, cssName=null, pathUrl=/manage/tools/customerservice, type=1, permissionName=upms:desktop:look, permission=null, status=1, sort=100, createTime=Sat Jul 06 01:13:37 CST 2019, updateTime=Mon Jul 13 12:59:46 CST 2020, child=[]), UpmnPermission(permissionId=104, systemId=1, parentId=91, parentIdAndLevel=null, menuLevel=1, menuName=吐字机, cssName=null, pathUrl=/manage/tools/enunciationmachine, type=1, permissionName=upms:desktop:writer, permission=null, status=1, sort=100, createTime=Sat Jul 06 02:47:20 CST 2019, updateTime=Mon Jul 13 12:59:46 CST 2020, child=[]), UpmnPermission(permissionId=105, systemId=1, parentId=91, parentIdAndLevel=null, menuLevel=1, menuName=自检机, cssName=null, pathUrl=/manage/tools/autocheck, type=1, permissionName=upms:desktop:check, permission=null, status=1, sort=100, createTime=Sat Jul 06 03:02:11 CST 2019, updateTime=Mon Jul 13 12:59:46 CST 2020, child=[]), UpmnPermission(permissionId=111, systemId=1, parentId=91, parentIdAndLevel=null, menuLevel=1, menuName=许愿墙, cssName=null, pathUrl=/manage/tools/wishingwall, type=1, permissionName=upms:tools:read, permission=null, status=1, sort=100, createTime=Sat Jul 06 22:08:47 CST 2019, updateTime=Mon Jul 13 12:59:46 CST 2020, child=[]), UpmnPermission(permissionId=112, systemId=1, parentId=91, parentIdAndLevel=null, menuLevel=1, menuName=防控3D预警, cssName=null, pathUrl=/manage/tools/d3effects, type=1, permissionName=upms:tools:create, permission=null, status=1, sort=100, createTime=Sat Jul 06 22:41:45 CST 2019, updateTime=Mon Jul 13 12:59:46 CST 2020, child=[]), UpmnPermission(permissionId=113, systemId=1, parentId=91, parentIdAndLevel=null, menuLevel=1, menuName=网络架子鼓, cssName=null, pathUrl=/manage/tools/networkDrumSet, type=1, permissionName=upms:tools:look, permission=null, status=1, sort=100, createTime=Mon Jul 08 20:19:06 CST 2019, updateTime=Mon Jul 13 12:59:46 CST 2020, child=[]), UpmnPermission(permissionId=114, systemId=1, parentId=91, parentIdAndLevel=null, menuLevel=1, menuName=网络钢琴, cssName=null, pathUrl=/manage/tools/networkPiano, type=1, permissionName=upms:tools:look, permission=null, status=1, sort=100, createTime=Mon Jul 08 20:58:01 CST 2019, updateTime=Mon Jul 13 12:59:46 CST 2020, child=[]), UpmnPermission(permissionId=115, systemId=1, parentId=91, parentIdAndLevel=null, menuLevel=1, menuName=碎片相册, cssName=null, pathUrl=/manage/tools/fragmentaryAlbum, type=1, permissionName=upms:tools:look, permission=null, status=1, sort=100, createTime=Mon Jul 08 21:34:52 CST 2019, updateTime=Mon Jul 13 12:59:46 CST 2020, child=[]), UpmnPermission(permissionId=116, systemId=1, parentId=91, parentIdAndLevel=null, menuLevel=1, menuName=图像标注特效, cssName=null, pathUrl=/manage/tools/annotationEffect, type=1, permissionName=upms:tools:read, permission=null, status=1, sort=100, createTime=Mon Jul 08 21:50:34 CST 2019, updateTime=Mon Jul 13 12:59:46 CST 2020, child=[])])
UpmnPermission(permissionId=109, systemId=1, parentId=0, parentIdAndLevel=null, menuLevel=1, menuName=监控管理, cssName=zmdi zmdi-lock-outline, pathUrl=null, type=1, permissionName=null, permission=null, status=1, sort=100, createTime=Sat Jul 11 18:34:07 CST 2020, updateTime=Sat Jul 11 18:34:07 CST 2020, child=[UpmnPermission(permissionId=110, systemId=1, parentId=109, parentIdAndLevel=null, menuLevel=1, menuName=晋城运输监控, cssName=null, pathUrl=/manage/tools/realTimemonitor, type=1, permissionName=upms:tools:look, permission=null, status=1, sort=100, createTime=Sat Jul 06 15:41:19 CST 2019, updateTime=Mon Jul 13 12:59:46 CST 2020, child=[]), UpmnPermission(permissionId=119, systemId=1, parentId=109, parentIdAndLevel=null, menuLevel=1, menuName=设备管理, cssName=null, pathUrl=/manage/device/index, type=1, permissionName=upms:device:read, permission=null, status=1, sort=100, createTime=Sat Oct 26 10:01:46 CST 2019, updateTime=Mon Jul 13 12:59:46 CST 2020, child=[])])
2020-07-13 12:59:46,433 [http-nio-8822-exec-7] DEBUG o.j.s.c.d.m.u.m.UpmnPermissionMapper.selectList -[BaseJdbcLogger.java:143]- ==>  Preparing: SELECT permission_id,system_id,parent_id,menu_level,menu_name,icon_name AS cssName,path_url,type,permission_name,status,sort,create_time,update_time FROM upms_permission WHERE (system_id = ?) 
2020-07-13 12:59:46,434 [http-nio-8822-exec-7] DEBUG o.j.s.c.d.m.u.m.UpmnPermissionMapper.selectList -[BaseJdbcLogger.java:143]- ==> Parameters: 1(Integer)

#  三级树的查询
SELECT
    m1.permission_id AS id_001,
    m1.menu_name AS name_001,
    m2.permission_id AS id_002,
    m2.menu_name AS name_002,
    m3.permission_id AS id_003,
    m3.menu_name name_003
FROM
    upms_permission m1,
    upms_permission m2,
    upms_permission m3
WHERE
    m1.`permission_id` = m2.`parent_id`
AND m2.`permission_id` = m3.`parent_id`

你可能感兴趣的:(MyBatis实现递归获得树形结构的数据(1,菜单树,2,组织树))