mirror of
https://gitee.com/log4j/pig.git
synced 2024-12-22 12:48:58 +08:00
♻️ #I3F5WU 基于 Hutool TreeUtils 重构目前系统自定义使用的TreeUtil
This commit is contained in:
parent
435432f4b1
commit
123a9da368
68
db/pig.sql
68
db/pig.sql
@ -158,20 +158,20 @@ CREATE TABLE `sys_log` (
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `sys_menu`;
|
||||
CREATE TABLE `sys_menu` (
|
||||
`menu_id` int(11) NOT NULL AUTO_INCREMENT COMMENT '菜单ID',
|
||||
`name` varchar(32) NOT NULL COMMENT '菜单名称',
|
||||
`permission` varchar(32) DEFAULT NULL COMMENT '菜单权限标识',
|
||||
`path` varchar(128) DEFAULT NULL COMMENT '前端URL',
|
||||
`parent_id` int(11) DEFAULT NULL COMMENT '父菜单ID',
|
||||
`icon` varchar(32) DEFAULT NULL COMMENT '图标',
|
||||
`component` varchar(64) DEFAULT NULL COMMENT 'VUE页面',
|
||||
`sort` int(11) DEFAULT '1' COMMENT '排序值',
|
||||
`keep_alive` char(1) DEFAULT '0' COMMENT '0-开启,1- 关闭',
|
||||
`type` char(1) DEFAULT NULL COMMENT '菜单类型 (0菜单 1按钮)',
|
||||
`create_time` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
`update_time` datetime NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||
`del_flag` char(1) DEFAULT '0' COMMENT '逻辑删除标记(0--正常 1--删除)',
|
||||
PRIMARY KEY (`menu_id`)
|
||||
`menu_id` int(11) NOT NULL AUTO_INCREMENT COMMENT '菜单ID',
|
||||
`name` varchar(32) NOT NULL COMMENT '菜单名称',
|
||||
`permission` varchar(32) DEFAULT NULL COMMENT '菜单权限标识',
|
||||
`path` varchar(128) DEFAULT NULL COMMENT '前端URL',
|
||||
`parent_id` int(11) DEFAULT NULL COMMENT '父菜单ID',
|
||||
`icon` varchar(32) DEFAULT NULL COMMENT '图标',
|
||||
`component` varchar(64) DEFAULT NULL COMMENT 'VUE页面',
|
||||
`sort` int(11) NOT NULL DEFAULT '1' COMMENT '排序值',
|
||||
`keep_alive` char(1) DEFAULT '0' COMMENT '0-开启,1- 关闭',
|
||||
`type` char(1) DEFAULT NULL COMMENT '菜单类型 (0菜单 1按钮)',
|
||||
`create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
`update_time` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||
`del_flag` char(1) DEFAULT '0' COMMENT '逻辑删除标记(0--正常 1--删除)',
|
||||
PRIMARY KEY (`menu_id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=10000 DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='菜单权限表';
|
||||
|
||||
-- ----------------------------
|
||||
@ -180,35 +180,35 @@ CREATE TABLE `sys_menu` (
|
||||
BEGIN;
|
||||
INSERT INTO `sys_menu` VALUES (1000, '权限管理', NULL, '/admin', -1, 'icon-quanxianguanli', NULL, 0, '0', '0', '2018-09-28 08:29:53', '2020-03-11 23:58:18', '0');
|
||||
INSERT INTO `sys_menu` VALUES (1100, '用户管理', NULL, '/admin/user/index', 1000, 'icon-yonghuguanli', NULL, 1, '0', '0', '2017-11-02 22:24:37', '2020-03-12 00:12:57', '0');
|
||||
INSERT INTO `sys_menu` VALUES (1101, '用户新增', 'sys_user_add', NULL, 1100, NULL, NULL, NULL, '0', '1', '2017-11-08 09:52:09', '2018-09-28 09:06:34', '0');
|
||||
INSERT INTO `sys_menu` VALUES (1102, '用户修改', 'sys_user_edit', NULL, 1100, NULL, NULL, NULL, '0', '1', '2017-11-08 09:52:48', '2018-09-28 09:06:37', '0');
|
||||
INSERT INTO `sys_menu` VALUES (1103, '用户删除', 'sys_user_del', NULL, 1100, NULL, NULL, NULL, '0', '1', '2017-11-08 09:54:01', '2018-09-28 09:06:42', '0');
|
||||
INSERT INTO `sys_menu` VALUES (1101, '用户新增', 'sys_user_add', NULL, 1100, NULL, NULL, 1, '0', '1', '2017-11-08 09:52:09', '2021-05-25 06:48:34', '0');
|
||||
INSERT INTO `sys_menu` VALUES (1102, '用户修改', 'sys_user_edit', NULL, 1100, NULL, NULL, 1, '0', '1', '2017-11-08 09:52:48', '2021-05-25 06:48:34', '0');
|
||||
INSERT INTO `sys_menu` VALUES (1103, '用户删除', 'sys_user_del', NULL, 1100, NULL, NULL, 1, '0', '1', '2017-11-08 09:54:01', '2021-05-25 06:48:34', '0');
|
||||
INSERT INTO `sys_menu` VALUES (1200, '菜单管理', NULL, '/admin/menu/index', 1000, 'icon-caidanguanli', NULL, 2, '0', '0', '2017-11-08 09:57:27', '2020-03-12 00:13:52', '0');
|
||||
INSERT INTO `sys_menu` VALUES (1201, '菜单新增', 'sys_menu_add', NULL, 1200, NULL, NULL, NULL, '0', '1', '2017-11-08 10:15:53', '2018-09-28 09:07:16', '0');
|
||||
INSERT INTO `sys_menu` VALUES (1202, '菜单修改', 'sys_menu_edit', NULL, 1200, NULL, NULL, NULL, '0', '1', '2017-11-08 10:16:23', '2018-09-28 09:07:18', '0');
|
||||
INSERT INTO `sys_menu` VALUES (1203, '菜单删除', 'sys_menu_del', NULL, 1200, NULL, NULL, NULL, '0', '1', '2017-11-08 10:16:43', '2018-09-28 09:07:22', '0');
|
||||
INSERT INTO `sys_menu` VALUES (1201, '菜单新增', 'sys_menu_add', NULL, 1200, NULL, NULL, 1, '0', '1', '2017-11-08 10:15:53', '2021-05-25 06:48:34', '0');
|
||||
INSERT INTO `sys_menu` VALUES (1202, '菜单修改', 'sys_menu_edit', NULL, 1200, NULL, NULL, 1, '0', '1', '2017-11-08 10:16:23', '2021-05-25 06:48:34', '0');
|
||||
INSERT INTO `sys_menu` VALUES (1203, '菜单删除', 'sys_menu_del', NULL, 1200, NULL, NULL, 1, '0', '1', '2017-11-08 10:16:43', '2021-05-25 06:48:34', '0');
|
||||
INSERT INTO `sys_menu` VALUES (1300, '角色管理', NULL, '/admin/role/index', 1000, 'icon-jiaoseguanli', NULL, 3, '0', '0', '2017-11-08 10:13:37', '2020-03-12 00:15:40', '0');
|
||||
INSERT INTO `sys_menu` VALUES (1301, '角色新增', 'sys_role_add', NULL, 1300, NULL, NULL, NULL, '0', '1', '2017-11-08 10:14:18', '2018-09-28 09:07:46', '0');
|
||||
INSERT INTO `sys_menu` VALUES (1302, '角色修改', 'sys_role_edit', NULL, 1300, NULL, NULL, NULL, '0', '1', '2017-11-08 10:14:41', '2018-09-28 09:07:49', '0');
|
||||
INSERT INTO `sys_menu` VALUES (1303, '角色删除', 'sys_role_del', NULL, 1300, NULL, NULL, NULL, '0', '1', '2017-11-08 10:14:59', '2018-09-28 09:07:53', '0');
|
||||
INSERT INTO `sys_menu` VALUES (1304, '分配权限', 'sys_role_perm', NULL, 1300, NULL, NULL, NULL, '0', '1', '2018-04-20 07:22:55', '2018-09-28 09:13:23', '0');
|
||||
INSERT INTO `sys_menu` VALUES (1301, '角色新增', 'sys_role_add', NULL, 1300, NULL, NULL, 1, '0', '1', '2017-11-08 10:14:18', '2021-05-25 06:48:34', '0');
|
||||
INSERT INTO `sys_menu` VALUES (1302, '角色修改', 'sys_role_edit', NULL, 1300, NULL, NULL, 1, '0', '1', '2017-11-08 10:14:41', '2021-05-25 06:48:34', '0');
|
||||
INSERT INTO `sys_menu` VALUES (1303, '角色删除', 'sys_role_del', NULL, 1300, NULL, NULL, 1, '0', '1', '2017-11-08 10:14:59', '2021-05-25 06:48:34', '0');
|
||||
INSERT INTO `sys_menu` VALUES (1304, '分配权限', 'sys_role_perm', NULL, 1300, NULL, NULL, 1, '0', '1', '2018-04-20 07:22:55', '2021-05-25 06:48:34', '0');
|
||||
INSERT INTO `sys_menu` VALUES (1400, '部门管理', NULL, '/admin/dept/index', 1000, 'icon-web-icon-', NULL, 4, '0', '0', '2018-01-20 13:17:19', '2020-03-12 00:15:44', '0');
|
||||
INSERT INTO `sys_menu` VALUES (1401, '部门新增', 'sys_dept_add', NULL, 1400, NULL, NULL, NULL, '0', '1', '2018-01-20 14:56:16', '2018-09-28 09:08:13', '0');
|
||||
INSERT INTO `sys_menu` VALUES (1402, '部门修改', 'sys_dept_edit', NULL, 1400, NULL, NULL, NULL, '0', '1', '2018-01-20 14:56:59', '2018-09-28 09:08:16', '0');
|
||||
INSERT INTO `sys_menu` VALUES (1403, '部门删除', 'sys_dept_del', NULL, 1400, NULL, NULL, NULL, '0', '1', '2018-01-20 14:57:28', '2018-09-28 09:08:18', '0');
|
||||
INSERT INTO `sys_menu` VALUES (1401, '部门新增', 'sys_dept_add', NULL, 1400, NULL, NULL, 1, '0', '1', '2018-01-20 14:56:16', '2021-05-25 06:48:34', '0');
|
||||
INSERT INTO `sys_menu` VALUES (1402, '部门修改', 'sys_dept_edit', NULL, 1400, NULL, NULL, 1, '0', '1', '2018-01-20 14:56:59', '2021-05-25 06:48:34', '0');
|
||||
INSERT INTO `sys_menu` VALUES (1403, '部门删除', 'sys_dept_del', NULL, 1400, NULL, NULL, 1, '0', '1', '2018-01-20 14:57:28', '2021-05-25 06:48:34', '0');
|
||||
INSERT INTO `sys_menu` VALUES (2000, '系统管理', NULL, '/setting', -1, 'icon-xitongguanli', NULL, 1, '0', '0', '2017-11-07 20:56:00', '2020-03-11 23:52:53', '0');
|
||||
INSERT INTO `sys_menu` VALUES (2100, '日志管理', NULL, '/admin/log/index', 2000, 'icon-rizhiguanli', NULL, 5, '0', '0', '2017-11-20 14:06:22', '2020-03-12 00:15:49', '0');
|
||||
INSERT INTO `sys_menu` VALUES (2101, '日志删除', 'sys_log_del', NULL, 2100, NULL, NULL, NULL, '0', '1', '2017-11-20 20:37:37', '2018-09-28 09:08:44', '0');
|
||||
INSERT INTO `sys_menu` VALUES (2101, '日志删除', 'sys_log_del', NULL, 2100, NULL, NULL, 1, '0', '1', '2017-11-20 20:37:37', '2021-05-25 06:48:34', '0');
|
||||
INSERT INTO `sys_menu` VALUES (2200, '字典管理', NULL, '/admin/dict/index', 2000, 'icon-navicon-zdgl', NULL, 6, '0', '0', '2017-11-29 11:30:52', '2020-03-12 00:15:58', '0');
|
||||
INSERT INTO `sys_menu` VALUES (2201, '字典删除', 'sys_dict_del', NULL, 2200, NULL, NULL, NULL, '0', '1', '2017-11-29 11:30:11', '2018-09-28 09:09:10', '0');
|
||||
INSERT INTO `sys_menu` VALUES (2202, '字典新增', 'sys_dict_add', NULL, 2200, NULL, NULL, NULL, '0', '1', '2018-05-11 22:34:55', '2018-09-28 09:09:12', '0');
|
||||
INSERT INTO `sys_menu` VALUES (2203, '字典修改', 'sys_dict_edit', NULL, 2200, NULL, NULL, NULL, '0', '1', '2018-05-11 22:36:03', '2018-09-28 09:09:16', '0');
|
||||
INSERT INTO `sys_menu` VALUES (2201, '字典删除', 'sys_dict_del', NULL, 2200, NULL, NULL, 1, '0', '1', '2017-11-29 11:30:11', '2021-05-25 06:48:34', '0');
|
||||
INSERT INTO `sys_menu` VALUES (2202, '字典新增', 'sys_dict_add', NULL, 2200, NULL, NULL, 1, '0', '1', '2018-05-11 22:34:55', '2021-05-25 06:48:34', '0');
|
||||
INSERT INTO `sys_menu` VALUES (2203, '字典修改', 'sys_dict_edit', NULL, 2200, NULL, NULL, 1, '0', '1', '2018-05-11 22:36:03', '2021-05-25 06:48:34', '0');
|
||||
INSERT INTO `sys_menu` VALUES (2300, '令牌管理', NULL, '/admin/token/index', 2000, 'icon-denglvlingpai', NULL, 11, '0', '0', '2018-09-04 05:58:41', '2020-03-13 12:57:25', '0');
|
||||
INSERT INTO `sys_menu` VALUES (2301, '令牌删除', 'sys_token_del', NULL, 2300, NULL, NULL, 1, '0', '1', '2018-09-04 05:59:50', '2020-03-13 12:57:34', '0');
|
||||
INSERT INTO `sys_menu` VALUES (2400, '终端管理', '', '/admin/client/index', 2000, 'icon-shouji', NULL, 9, '0', '0', '2018-01-20 13:17:19', '2020-03-12 00:15:54', '0');
|
||||
INSERT INTO `sys_menu` VALUES (2401, '客户端新增', 'sys_client_add', NULL, 2400, '1', NULL, NULL, '0', '1', '2018-05-15 21:35:18', '2018-09-28 09:10:25', '0');
|
||||
INSERT INTO `sys_menu` VALUES (2402, '客户端修改', 'sys_client_edit', NULL, 2400, NULL, NULL, NULL, '0', '1', '2018-05-15 21:37:06', '2018-09-28 09:10:27', '0');
|
||||
INSERT INTO `sys_menu` VALUES (2403, '客户端删除', 'sys_client_del', NULL, 2400, NULL, NULL, NULL, '0', '1', '2018-05-15 21:39:16', '2018-09-28 09:10:30', '0');
|
||||
INSERT INTO `sys_menu` VALUES (2401, '客户端新增', 'sys_client_add', NULL, 2400, '1', NULL, 1, '0', '1', '2018-05-15 21:35:18', '2021-05-25 06:48:34', '0');
|
||||
INSERT INTO `sys_menu` VALUES (2402, '客户端修改', 'sys_client_edit', NULL, 2400, NULL, NULL, 1, '0', '1', '2018-05-15 21:37:06', '2021-05-25 06:48:34', '0');
|
||||
INSERT INTO `sys_menu` VALUES (2403, '客户端删除', 'sys_client_del', NULL, 2400, NULL, NULL, 1, '0', '1', '2018-05-15 21:39:16', '2021-05-25 06:48:34', '0');
|
||||
INSERT INTO `sys_menu` VALUES (2500, '服务监控', NULL, 'http://localhost:5001', 2000, 'icon-server', NULL, 10, '0', '0', '2018-06-26 10:50:32', '2019-02-01 20:41:30', '0');
|
||||
INSERT INTO `sys_menu` VALUES (3000, '开发平台', NULL, '/gen', -1, 'icon-shejiyukaifa-', NULL, 3, '1', '0', '2020-03-11 22:15:40', '2020-03-11 23:52:54', '0');
|
||||
INSERT INTO `sys_menu` VALUES (3100, '数据源管理', NULL, '/gen/datasource', 3000, 'icon-mysql', NULL, 1, '1', '0', '2020-03-11 22:17:05', '2020-03-12 00:16:09', '0');
|
||||
|
@ -1,32 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2020 pig4cloud Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.pig4cloud.pig.admin.api.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* @author lengleng
|
||||
* @date 2019/2/1 部门树
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class DeptTree extends TreeNode {
|
||||
|
||||
private String name;
|
||||
|
||||
}
|
@ -1,113 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2020 pig4cloud Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.pig4cloud.pig.admin.api.dto;
|
||||
|
||||
import com.pig4cloud.pig.admin.api.vo.MenuVO;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author lengleng
|
||||
* @date 2017年11月9日23:33:27
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class MenuTree extends TreeNode implements Serializable {
|
||||
|
||||
/**
|
||||
* 菜单图标
|
||||
*/
|
||||
private String icon;
|
||||
|
||||
/**
|
||||
* 菜单名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
private boolean spread = false;
|
||||
|
||||
/**
|
||||
* 前端路由标识路径
|
||||
*/
|
||||
private String path;
|
||||
|
||||
/**
|
||||
* 路由缓冲
|
||||
*/
|
||||
private String keepAlive;
|
||||
|
||||
/**
|
||||
* 权限编码
|
||||
*/
|
||||
private String permission;
|
||||
|
||||
/**
|
||||
* 菜单类型 (0菜单 1按钮)
|
||||
*/
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 菜单标签
|
||||
*/
|
||||
private String label;
|
||||
|
||||
/**
|
||||
* 排序值
|
||||
*/
|
||||
private Integer sort;
|
||||
|
||||
/**
|
||||
* 是否包含子节点
|
||||
*
|
||||
* @since 3.7
|
||||
*/
|
||||
private Boolean hasChildren;
|
||||
|
||||
public MenuTree() {
|
||||
}
|
||||
|
||||
public MenuTree(int id, String name, int parentId) {
|
||||
this.id = id;
|
||||
this.parentId = parentId;
|
||||
this.name = name;
|
||||
this.label = name;
|
||||
}
|
||||
|
||||
public MenuTree(int id, String name, MenuTree parent) {
|
||||
this.id = id;
|
||||
this.parentId = parent.getId();
|
||||
this.name = name;
|
||||
this.label = name;
|
||||
}
|
||||
|
||||
public MenuTree(MenuVO menuVo) {
|
||||
this.id = menuVo.getMenuId();
|
||||
this.parentId = menuVo.getParentId();
|
||||
this.icon = menuVo.getIcon();
|
||||
this.name = menuVo.getName();
|
||||
this.path = menuVo.getPath();
|
||||
this.type = menuVo.getType();
|
||||
this.permission = menuVo.getPermission();
|
||||
this.label = menuVo.getName();
|
||||
this.sort = menuVo.getSort();
|
||||
this.keepAlive = menuVo.getKeepAlive();
|
||||
this.hasChildren = false;
|
||||
}
|
||||
|
||||
}
|
@ -1,50 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2020 pig4cloud Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
*
|
||||
* 此类来自 https://gitee.com/geek_qi/cloud-platform/blob/master/ace-common/src/main/java/com/github/wxiaoqi/security/common/vo/TreeNode.java
|
||||
* @ Apache-2.0
|
||||
*/
|
||||
|
||||
package com.pig4cloud.pig.admin.api.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author ace
|
||||
* @author lengleng
|
||||
* @date 2017年11月9日23:33:45
|
||||
*/
|
||||
@Data
|
||||
public class TreeNode {
|
||||
|
||||
protected int id;
|
||||
|
||||
protected int parentId;
|
||||
|
||||
protected List<TreeNode> children = new ArrayList<TreeNode>();
|
||||
|
||||
protected Boolean hasChildren;
|
||||
|
||||
public void add(TreeNode node) {
|
||||
children.add(node);
|
||||
}
|
||||
|
||||
}
|
@ -1,101 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2020 pig4cloud Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
*
|
||||
* 此类来自 https://gitee.com/geek_qi/cloud-platform/blob/master/ace-common/src/main/java/com/github/wxiaoqi/security/common/util/TreeUtil.java
|
||||
* @ Apache-2.0
|
||||
*/
|
||||
|
||||
package com.pig4cloud.pig.admin.api.util;
|
||||
|
||||
import com.pig4cloud.pig.admin.api.dto.MenuTree;
|
||||
import com.pig4cloud.pig.admin.api.dto.TreeNode;
|
||||
import com.pig4cloud.pig.admin.api.entity.SysMenu;
|
||||
import lombok.experimental.UtilityClass;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Ace
|
||||
* @author lengleng
|
||||
* @date 2020-02-09
|
||||
*/
|
||||
@UtilityClass
|
||||
public class TreeUtils {
|
||||
|
||||
/**
|
||||
* 两层循环实现建树
|
||||
* @param treeNodes 传入的树节点列表
|
||||
* @return
|
||||
*/
|
||||
public <T extends TreeNode> List<T> build(List<T> treeNodes, Object root) {
|
||||
|
||||
List<T> trees = new ArrayList<>();
|
||||
|
||||
for (T treeNode : treeNodes) {
|
||||
|
||||
if (root.equals(treeNode.getParentId())) {
|
||||
trees.add(treeNode);
|
||||
}
|
||||
|
||||
for (T it : treeNodes) {
|
||||
if (it.getParentId() == treeNode.getId()) {
|
||||
if (treeNode.getChildren() == null) {
|
||||
treeNode.setChildren(new ArrayList<>());
|
||||
}
|
||||
treeNode.add(it);
|
||||
treeNode.setHasChildren(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
return trees;
|
||||
}
|
||||
|
||||
/**
|
||||
* 使用递归方法建树
|
||||
* @param treeNodes
|
||||
* @return
|
||||
*/
|
||||
public <T extends TreeNode> List<T> buildByRecursive(List<T> treeNodes, Object root) {
|
||||
List<T> trees = new ArrayList<T>();
|
||||
for (T treeNode : treeNodes) {
|
||||
if (root.equals(treeNode.getParentId())) {
|
||||
trees.add(findChildren(treeNode, treeNodes));
|
||||
}
|
||||
}
|
||||
return trees;
|
||||
}
|
||||
|
||||
/**
|
||||
* 递归查找子节点
|
||||
* @param treeNodes
|
||||
* @return
|
||||
*/
|
||||
public <T extends TreeNode> T findChildren(T treeNode, List<T> treeNodes) {
|
||||
for (T it : treeNodes) {
|
||||
if (treeNode.getId() == it.getParentId()) {
|
||||
if (treeNode.getChildren() == null) {
|
||||
treeNode.setChildren(new ArrayList<>());
|
||||
}
|
||||
treeNode.add(findChildren(it, treeNodes));
|
||||
}
|
||||
}
|
||||
return treeNode;
|
||||
}
|
||||
|
||||
}
|
@ -1,116 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2020 pig4cloud Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.pig4cloud.pig.admin.api.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 菜单权限表
|
||||
* </p>
|
||||
*
|
||||
* @author lengleng
|
||||
* @since 2017-11-08
|
||||
*/
|
||||
@Data
|
||||
public class MenuVO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 菜单ID
|
||||
*/
|
||||
private Integer menuId;
|
||||
|
||||
/**
|
||||
* 菜单名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 菜单权限标识
|
||||
*/
|
||||
private String permission;
|
||||
|
||||
/**
|
||||
* 父菜单ID
|
||||
*/
|
||||
private Integer parentId;
|
||||
|
||||
/**
|
||||
* 图标
|
||||
*/
|
||||
private String icon;
|
||||
|
||||
/**
|
||||
* 前端路由标识路径
|
||||
*/
|
||||
private String path;
|
||||
|
||||
/**
|
||||
* 排序值
|
||||
*/
|
||||
private Integer sort;
|
||||
|
||||
/**
|
||||
* 菜单类型 (0菜单 1按钮)
|
||||
*/
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 是否缓冲
|
||||
*/
|
||||
private String keepAlive;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
* 0--正常 1--删除
|
||||
*/
|
||||
private String delFlag;
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return menuId.hashCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* menuId 相同则相同
|
||||
* @param obj
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj instanceof MenuVO) {
|
||||
Integer targetMenuId = ((MenuVO) obj).getMenuId();
|
||||
return menuId.equals(targetMenuId);
|
||||
}
|
||||
return super.equals(obj);
|
||||
}
|
||||
|
||||
}
|
@ -17,7 +17,6 @@
|
||||
package com.pig4cloud.pig.admin.controller;
|
||||
|
||||
import com.pig4cloud.pig.admin.api.entity.SysMenu;
|
||||
import com.pig4cloud.pig.admin.api.vo.MenuVO;
|
||||
import com.pig4cloud.pig.admin.service.SysMenuService;
|
||||
import com.pig4cloud.pig.common.core.util.R;
|
||||
import com.pig4cloud.pig.common.log.annotation.SysLog;
|
||||
@ -53,7 +52,7 @@ public class MenuController {
|
||||
public R getUserMenu(Integer parentId) {
|
||||
|
||||
// 获取符合条件的菜单
|
||||
Set<MenuVO> all = new HashSet<>();
|
||||
Set<SysMenu> all = new HashSet<>();
|
||||
SecurityUtils.getRoles().forEach(roleId -> all.addAll(sysMenuService.findMenuByRoleId(roleId)));
|
||||
return R.ok(sysMenuService.filterMenu(all, parentId));
|
||||
}
|
||||
@ -77,7 +76,7 @@ public class MenuController {
|
||||
@GetMapping("/tree/{roleId}")
|
||||
public R getRoleTree(@PathVariable Integer roleId) {
|
||||
return R.ok(
|
||||
sysMenuService.findMenuByRoleId(roleId).stream().map(MenuVO::getMenuId).collect(Collectors.toList()));
|
||||
sysMenuService.findMenuByRoleId(roleId).stream().map(SysMenu::getMenuId).collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -18,7 +18,6 @@ package com.pig4cloud.pig.admin.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.pig4cloud.pig.admin.api.entity.SysMenu;
|
||||
import com.pig4cloud.pig.admin.api.vo.MenuVO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
@ -39,7 +38,7 @@ public interface SysMenuMapper extends BaseMapper<SysMenu> {
|
||||
* @param roleId 角色ID
|
||||
* @return
|
||||
*/
|
||||
List<MenuVO> listMenusByRoleId(Integer roleId);
|
||||
List<SysMenu> listMenusByRoleId(Integer roleId);
|
||||
|
||||
/**
|
||||
* 通过角色ID查询权限
|
||||
|
@ -16,8 +16,8 @@
|
||||
|
||||
package com.pig4cloud.pig.admin.service;
|
||||
|
||||
import cn.hutool.core.lang.tree.Tree;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.pig4cloud.pig.admin.api.dto.DeptTree;
|
||||
import com.pig4cloud.pig.admin.api.entity.SysDept;
|
||||
|
||||
import java.util.List;
|
||||
@ -36,13 +36,13 @@ public interface SysDeptService extends IService<SysDept> {
|
||||
* 查询部门树菜单
|
||||
* @return 树
|
||||
*/
|
||||
List<DeptTree> listDeptTrees();
|
||||
List<Tree<Integer>> listDeptTrees();
|
||||
|
||||
/**
|
||||
* 查询用户部门树
|
||||
* @return
|
||||
*/
|
||||
List<DeptTree> listCurrentUserDeptTrees();
|
||||
List<Tree<Integer>> listCurrentUserDeptTrees();
|
||||
|
||||
/**
|
||||
* 添加信息部门
|
||||
|
@ -16,10 +16,9 @@
|
||||
|
||||
package com.pig4cloud.pig.admin.service;
|
||||
|
||||
import cn.hutool.core.lang.tree.Tree;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.pig4cloud.pig.admin.api.dto.MenuTree;
|
||||
import com.pig4cloud.pig.admin.api.entity.SysMenu;
|
||||
import com.pig4cloud.pig.admin.api.vo.MenuVO;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
@ -39,12 +38,12 @@ public interface SysMenuService extends IService<SysMenu> {
|
||||
* @param roleId 角色ID
|
||||
* @return 菜单列表
|
||||
*/
|
||||
List<MenuVO> findMenuByRoleId(Integer roleId);
|
||||
List<SysMenu> findMenuByRoleId(Integer roleId);
|
||||
|
||||
/**
|
||||
* 级联删除菜单
|
||||
* @param id 菜单ID
|
||||
* @return true成功,false失败
|
||||
* @return true成功, false失败
|
||||
*/
|
||||
Boolean removeMenuById(Integer id);
|
||||
|
||||
@ -61,7 +60,7 @@ public interface SysMenuService extends IService<SysMenu> {
|
||||
* @param parentId 父节点ID
|
||||
* @return
|
||||
*/
|
||||
List<MenuTree> treeMenu(boolean lazy, Integer parentId);
|
||||
List<Tree<Integer>> treeMenu(boolean lazy, Integer parentId);
|
||||
|
||||
/**
|
||||
* 查询菜单
|
||||
@ -69,6 +68,6 @@ public interface SysMenuService extends IService<SysMenu> {
|
||||
* @param parentId
|
||||
* @return
|
||||
*/
|
||||
List<MenuTree> filterMenu(Set<MenuVO> menuSet, Integer parentId);
|
||||
List<Tree<Integer>> filterMenu(Set<SysMenu> menuSet, Integer parentId);
|
||||
|
||||
}
|
||||
|
@ -17,12 +17,13 @@
|
||||
package com.pig4cloud.pig.admin.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.lang.tree.Tree;
|
||||
import cn.hutool.core.lang.tree.TreeNode;
|
||||
import cn.hutool.core.lang.tree.TreeUtil;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.pig4cloud.pig.admin.api.dto.DeptTree;
|
||||
import com.pig4cloud.pig.admin.api.entity.SysDept;
|
||||
import com.pig4cloud.pig.admin.api.entity.SysDeptRelation;
|
||||
import com.pig4cloud.pig.admin.api.util.TreeUtils;
|
||||
import com.pig4cloud.pig.admin.mapper.SysDeptMapper;
|
||||
import com.pig4cloud.pig.admin.service.SysDeptRelationService;
|
||||
import com.pig4cloud.pig.admin.service.SysDeptService;
|
||||
@ -110,7 +111,7 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
|
||||
* @return 树
|
||||
*/
|
||||
@Override
|
||||
public List<DeptTree> listDeptTrees() {
|
||||
public List<Tree<Integer>> listDeptTrees() {
|
||||
return getDeptTree(this.list(Wrappers.emptyWrapper()));
|
||||
}
|
||||
|
||||
@ -119,7 +120,7 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<DeptTree> listCurrentUserDeptTrees() {
|
||||
public List<Tree<Integer>> listCurrentUserDeptTrees() {
|
||||
Integer deptId = SecurityUtils.getUser().getDeptId();
|
||||
List<Integer> descendantIdList = sysDeptRelationService
|
||||
.list(Wrappers.<SysDeptRelation>query().lambda().eq(SysDeptRelation::getAncestor, deptId)).stream()
|
||||
@ -134,16 +135,18 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
|
||||
* @param depts 部门
|
||||
* @return
|
||||
*/
|
||||
private List<DeptTree> getDeptTree(List<SysDept> depts) {
|
||||
List<DeptTree> treeList = depts.stream().filter(dept -> !dept.getDeptId().equals(dept.getParentId()))
|
||||
private List<Tree<Integer>> getDeptTree(List<SysDept> depts) {
|
||||
List<TreeNode<Integer>> collect = depts.stream()
|
||||
.filter(dept -> dept.getDeptId().intValue() != dept.getParentId())
|
||||
.sorted(Comparator.comparingInt(SysDept::getSort)).map(dept -> {
|
||||
DeptTree node = new DeptTree();
|
||||
node.setId(dept.getDeptId());
|
||||
node.setParentId(dept.getParentId());
|
||||
node.setName(dept.getName());
|
||||
return node;
|
||||
TreeNode<Integer> treeNode = new TreeNode();
|
||||
treeNode.setId(dept.getDeptId());
|
||||
treeNode.setParentId(dept.getParentId());
|
||||
treeNode.setName(dept.getName());
|
||||
return treeNode;
|
||||
}).collect(Collectors.toList());
|
||||
return TreeUtils.build(treeList, 0);
|
||||
|
||||
return TreeUtil.build(collect, 0);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -17,31 +17,32 @@
|
||||
package com.pig4cloud.pig.admin.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.lang.tree.Tree;
|
||||
import cn.hutool.core.lang.tree.TreeNode;
|
||||
import cn.hutool.core.lang.tree.TreeUtil;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.pig4cloud.pig.admin.api.dto.MenuTree;
|
||||
import com.pig4cloud.pig.admin.api.entity.SysMenu;
|
||||
import com.pig4cloud.pig.admin.api.entity.SysRoleMenu;
|
||||
import com.pig4cloud.pig.admin.api.util.TreeUtils;
|
||||
import com.pig4cloud.pig.admin.api.vo.MenuVO;
|
||||
import com.pig4cloud.pig.admin.mapper.SysMenuMapper;
|
||||
import com.pig4cloud.pig.admin.mapper.SysRoleMenuMapper;
|
||||
import com.pig4cloud.pig.admin.service.SysMenuService;
|
||||
import com.pig4cloud.pig.common.core.constant.CacheConstants;
|
||||
import com.pig4cloud.pig.common.core.constant.CommonConstants;
|
||||
import com.pig4cloud.pig.common.core.constant.enums.MenuTypeEnum;
|
||||
import com.pig4cloud.pig.common.core.util.R;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@ -60,14 +61,14 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
|
||||
|
||||
@Override
|
||||
@Cacheable(value = CacheConstants.MENU_DETAILS, key = "#roleId + '_menu'", unless = "#result == null")
|
||||
public List<MenuVO> findMenuByRoleId(Integer roleId) {
|
||||
public List<SysMenu> findMenuByRoleId(Integer roleId) {
|
||||
return baseMapper.listMenusByRoleId(roleId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 级联删除菜单
|
||||
* @param id 菜单ID
|
||||
* @return true成功,false失败
|
||||
* @return true成功, false失败
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@ -96,17 +97,23 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<MenuTree> treeMenu(boolean lazy, Integer parentId) {
|
||||
public List<Tree<Integer>> treeMenu(boolean lazy, Integer parentId) {
|
||||
if (!lazy) {
|
||||
return buildTree(baseMapper.selectList(Wrappers.<SysMenu>lambdaQuery().orderByAsc(SysMenu::getSort)),
|
||||
CommonConstants.MENU_TREE_ROOT_ID);
|
||||
List<TreeNode<Integer>> collect = baseMapper
|
||||
.selectList(Wrappers.<SysMenu>lambdaQuery().orderByAsc(SysMenu::getSort)).stream()
|
||||
.map(getNodeFunction()).collect(Collectors.toList());
|
||||
|
||||
return TreeUtil.build(collect, CommonConstants.MENU_TREE_ROOT_ID);
|
||||
}
|
||||
|
||||
Integer parent = parentId == null ? CommonConstants.MENU_TREE_ROOT_ID : parentId;
|
||||
return buildTree(
|
||||
baseMapper.selectList(
|
||||
Wrappers.<SysMenu>lambdaQuery().eq(SysMenu::getParentId, parent).orderByAsc(SysMenu::getSort)),
|
||||
parent);
|
||||
|
||||
List<TreeNode<Integer>> collect = baseMapper
|
||||
.selectList(
|
||||
Wrappers.<SysMenu>lambdaQuery().eq(SysMenu::getParentId, parent).orderByAsc(SysMenu::getSort))
|
||||
.stream().map(getNodeFunction()).collect(Collectors.toList());
|
||||
|
||||
return TreeUtil.build(collect, parent);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -116,38 +123,34 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<MenuTree> filterMenu(Set<MenuVO> all, Integer parentId) {
|
||||
List<MenuTree> menuTreeList = all.stream().filter(vo -> MenuTypeEnum.LEFT_MENU.getType().equals(vo.getType()))
|
||||
.map(MenuTree::new).sorted(Comparator.comparingInt(MenuTree::getSort)).collect(Collectors.toList());
|
||||
public List<Tree<Integer>> filterMenu(Set<SysMenu> all, Integer parentId) {
|
||||
List<TreeNode<Integer>> collect = all.stream()
|
||||
.filter(menu -> MenuTypeEnum.LEFT_MENU.getType().equals(menu.getType()))
|
||||
.map(getNodeFunction()).collect(Collectors.toList());
|
||||
Integer parent = parentId == null ? CommonConstants.MENU_TREE_ROOT_ID : parentId;
|
||||
return TreeUtils.build(menuTreeList, parent);
|
||||
return TreeUtil.build(collect, parent);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过sysMenu创建树形节点
|
||||
* @param menus
|
||||
* @param root
|
||||
* @return
|
||||
*/
|
||||
private List<MenuTree> buildTree(List<SysMenu> menus, int root) {
|
||||
List<MenuTree> trees = new ArrayList<>();
|
||||
MenuTree node;
|
||||
for (SysMenu menu : menus) {
|
||||
node = new MenuTree();
|
||||
@NotNull
|
||||
private Function<SysMenu, TreeNode<Integer>> getNodeFunction() {
|
||||
return menu -> {
|
||||
TreeNode<Integer> node = new TreeNode<>();
|
||||
node.setId(menu.getMenuId());
|
||||
node.setParentId(menu.getParentId());
|
||||
node.setName(menu.getName());
|
||||
node.setPath(menu.getPath());
|
||||
node.setPermission(menu.getPermission());
|
||||
node.setLabel(menu.getName());
|
||||
node.setIcon(menu.getIcon());
|
||||
node.setType(menu.getType());
|
||||
node.setSort(menu.getSort());
|
||||
node.setHasChildren(false);
|
||||
node.setKeepAlive(menu.getKeepAlive());
|
||||
trees.add(node);
|
||||
}
|
||||
return TreeUtils.build(trees, root);
|
||||
node.setParentId(menu.getParentId());
|
||||
node.setWeight(menu.getSort());
|
||||
// 扩展属性
|
||||
Map<String, Object> extra = new HashMap<>();
|
||||
extra.put("icon", menu.getIcon());
|
||||
extra.put("path", menu.getPath());
|
||||
extra.put("type", menu.getType());
|
||||
extra.put("permission", menu.getPermission());
|
||||
extra.put("label", menu.getName());
|
||||
extra.put("sort", menu.getSort());
|
||||
extra.put("keepAlive", menu.getKeepAlive());
|
||||
node.setExtra(extra);
|
||||
return node;
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -16,12 +16,6 @@
|
||||
|
||||
package com.pig4cloud.pig.admin.service.impl;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
@ -30,18 +24,10 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.pig4cloud.pig.admin.api.dto.UserDTO;
|
||||
import com.pig4cloud.pig.admin.api.dto.UserInfo;
|
||||
import com.pig4cloud.pig.admin.api.entity.SysDept;
|
||||
import com.pig4cloud.pig.admin.api.entity.SysRole;
|
||||
import com.pig4cloud.pig.admin.api.entity.SysUser;
|
||||
import com.pig4cloud.pig.admin.api.entity.SysUserRole;
|
||||
import com.pig4cloud.pig.admin.api.vo.MenuVO;
|
||||
import com.pig4cloud.pig.admin.api.entity.*;
|
||||
import com.pig4cloud.pig.admin.api.vo.UserVO;
|
||||
import com.pig4cloud.pig.admin.mapper.SysUserMapper;
|
||||
import com.pig4cloud.pig.admin.service.SysDeptService;
|
||||
import com.pig4cloud.pig.admin.service.SysMenuService;
|
||||
import com.pig4cloud.pig.admin.service.SysRoleService;
|
||||
import com.pig4cloud.pig.admin.service.SysUserRoleService;
|
||||
import com.pig4cloud.pig.admin.service.SysUserService;
|
||||
import com.pig4cloud.pig.admin.service.*;
|
||||
import com.pig4cloud.pig.common.core.constant.CacheConstants;
|
||||
import com.pig4cloud.pig.common.core.constant.CommonConstants;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@ -54,6 +40,12 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author lengleng
|
||||
* @date 2019/2/1
|
||||
@ -113,7 +105,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||
Set<String> permissions = new HashSet<>();
|
||||
roleIds.forEach(roleId -> {
|
||||
List<String> permissionList = sysMenuService.findMenuByRoleId(roleId).stream()
|
||||
.filter(menuVo -> StrUtil.isNotEmpty(menuVo.getPermission())).map(MenuVO::getPermission)
|
||||
.filter(menuVo -> StrUtil.isNotEmpty(menuVo.getPermission())).map(SysMenu::getPermission)
|
||||
.collect(Collectors.toList());
|
||||
permissions.addAll(permissionList);
|
||||
});
|
||||
|
@ -34,23 +34,8 @@
|
||||
<result column="del_flag" property="delFlag"/>
|
||||
</resultMap>
|
||||
|
||||
<resultMap id="MenuVoResultMap" type="com.pig4cloud.pig.admin.api.vo.MenuVO">
|
||||
<id column="menu_id" property="menuId"/>
|
||||
<result column="name" property="name"/>
|
||||
<result column="permission" property="permission"/>
|
||||
<result column="parent_id" property="parentId"/>
|
||||
<result column="icon" property="icon"/>
|
||||
<result column="path" property="path"/>
|
||||
<result column="sort" property="sort"/>
|
||||
<result column="keep_alive" property="keepAlive"/>
|
||||
<result column="type" property="type"/>
|
||||
<result column="create_time" property="createTime"/>
|
||||
<result column="update_time" property="updateTime"/>
|
||||
<result column="del_flag" property="delFlag"/>
|
||||
</resultMap>
|
||||
|
||||
<!--通过角色查询菜单信息-->
|
||||
<select id="listMenusByRoleId" resultMap="MenuVoResultMap">
|
||||
<select id="listMenusByRoleId" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
sys_menu.*
|
||||
FROM
|
||||
|
Loading…
Reference in New Issue
Block a user