Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit d2433f9

Browse files
权限修改,更新缓存
1 parent 0de07da commit d2433f9

File tree

4 files changed

+136
-66
lines changed

4 files changed

+136
-66
lines changed

‎src/main/java/com/study/shiro/MyShiroRealm.java‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@
1111
import org.apache.shiro.realm.AuthorizingRealm;
1212
import org.apache.shiro.session.Session;
1313
import org.apache.shiro.subject.PrincipalCollection;
14-
import org.apache.shiro.subject.SimplePrincipalCollection;
1514
import org.apache.shiro.util.ByteSource;
16-
import tk.mybatis.mapper.entity.Example;
1715

1816
import javax.annotation.Resource;
1917
import java.util.HashMap;
@@ -72,11 +70,11 @@ protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken token)
7270
/**
7371
* 指定principalCollection 清除
7472
*/
75-
public void clearCachedAuthorizationInfo(PrincipalCollection principalCollection) {
73+
/* public void clearCachedAuthorizationInfo(PrincipalCollection principalCollection) {
7674
7775
SimplePrincipalCollection principals = new SimplePrincipalCollection(
7876
principalCollection, getName());
7977
super.clearCachedAuthorizationInfo(principals);
8078
}
81-
79+
*/
8280
}

‎src/main/java/com/study/shiro/ShiroService.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public void updatePermission() {
9898
* 根据userId 清除当前session存在的用户的权限缓存
9999
* @param userIds 已经修改了权限的userId
100100
*/
101-
public void clearUserAuthByUserId(List<Integer> userIds){
101+
/* public void clearUserAuthByUserId(List<Integer> userIds){
102102
if(null == userIds || userIds.size() == 0) return ;
103103
//获取所有session
104104
Collection<Session> sessions = redisSessionDAO.getActiveSessions();
@@ -128,5 +128,5 @@ public void clearUserAuthByUserId(List<Integer> userIds){
128128
for (SimplePrincipalCollection simplePrincipalCollection : list) {
129129
realm.clearCachedAuthorizationInfo(simplePrincipalCollection);
130130
}
131-
}
131+
}*/
132132
}

‎src/main/resources/shiro.sql‎

Lines changed: 132 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,75 +1,75 @@
11
/*
22
Navicat MySQL Data Transfer
33
4-
Source Server : my
5-
Source Server Version : 50520
4+
Source Server : jj
5+
Source Server Version : 50022
66
Source Host : localhost:3306
77
Source Database : shiro
88
99
Target Server Type : MYSQL
10-
Target Server Version : 50520
10+
Target Server Version : 50022
1111
File Encoding : 65001
1212
13-
Date: 2017-04-20 16:15:17
13+
Date: 2017-05-07 21:00:04
1414
*/
1515

1616
SET FOREIGN_KEY_CHECKS=0;
1717

1818
-- ----------------------------
19-
-- Table structure for resources
19+
-- Table structure for `resources`
2020
-- ----------------------------
2121
DROP TABLE IF EXISTS `resources`;
2222
CREATE TABLE `resources` (
23-
`id` int(11) NOT NULL AUTO_INCREMENT,
24-
`name` varchar(255) DEFAULT NULL COMMENT '资源名称',
25-
`resKey` varchar(255) DEFAULT NULL COMMENT '资源key',
26-
`resUrl` varchar(255) DEFAULT NULL COMMENT '资源url',
27-
`type` int(11) DEFAULT NULL COMMENT '资源类型 1:菜单 2:按钮',
28-
`parentId` int(11) DEFAULT NULL COMMENT '父资源',
29-
`sort` int(11) DEFAULT NULL COMMENT '排序',
30-
PRIMARY KEY (`id`)
31-
) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8;
23+
`id` int(11) NOT NULL auto_increment,
24+
`name` varchar(255) default NULL COMMENT '资源名称',
25+
`resUrl` varchar(255) default NULL COMMENT '资源url',
26+
`type` int(11) default NULL COMMENT '资源类型 1:菜单 2:按钮',
27+
`parentId` int(11) default NULL COMMENT '父资源',
28+
`sort` int(11) default NULL COMMENT '排序',
29+
PRIMARY KEY (`id`)
30+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
3231

3332
-- ----------------------------
3433
-- Records of resources
3534
-- ----------------------------
36-
INSERT INTO `resources` VALUES ('1', '系统设置', 'system', '/system', '0', '0', '1');
37-
INSERT INTO `resources` VALUES ('2', '用户管理', 'sys_user_list', '/index.do', '1', '1', '2');
38-
INSERT INTO `resources` VALUES ('3', '角色管理', 'sys_role_list', '/roles.do', '1', '1', '3');
39-
INSERT INTO `resources` VALUES ('4', '资源管理', 'sys_res_list', '/resources.do', '1', '1', '4');
40-
INSERT INTO `resources` VALUES ('5', '添加用户', 'sys_user_add', '/user/addUser.do', '2', '2', '5');
41-
INSERT INTO `resources` VALUES ('6', '删除用户', 'sys_user_del', '/user/delUser.do', '2', '2', '6');
42-
INSERT INTO `resources` VALUES ('7', '添加角色', 'sys_role_add', '/role/addRole.do', '2', '3', '7');
43-
INSERT INTO `resources` VALUES ('8', '删除角色', 'sys_role_del', '/role/delRole.do', '2', '3', '8');
44-
INSERT INTO `resources` VALUES ('9', '添加资源', 'sys_res_add', '/resources/addResources.do', '2', '4', '9');
45-
INSERT INTO `resources` VALUES ('10', '删除资源', 'sys_res_del', '/resources/delResources.do', '2', '4', '10');
35+
INSERT INTO `resources` VALUES ('1', '系统设置', '/system', '0', '0', '1');
36+
INSERT INTO `resources` VALUES ('2', '用户管理', '/usersPage', '1', '1', '2');
37+
INSERT INTO `resources` VALUES ('3', '角色管理', '/rolesPage', '1', '1', '3');
38+
INSERT INTO `resources` VALUES ('4', '资源管理', '/resourcesPage', '1', '1', '4');
39+
INSERT INTO `resources` VALUES ('5', '添加用户', '/users/add', '2', '2', '5');
40+
INSERT INTO `resources` VALUES ('6', '删除用户', '/users/delete', '2', '2', '6');
41+
INSERT INTO `resources` VALUES ('7', '添加角色', '/roles/add', '2', '3', '7');
42+
INSERT INTO `resources` VALUES ('8', '删除角色', '/roles/delete', '2', '3', '8');
43+
INSERT INTO `resources` VALUES ('9', '添加资源', '/resources/add', '2', '4', '9');
44+
INSERT INTO `resources` VALUES ('10', '删除资源', '/resources/delete', '2', '4', '10');
45+
INSERT INTO `resources` VALUES ('11', '分配角色', '/users/saveUserRoles', '2', '2', '11');
46+
INSERT INTO `resources` VALUES ('13', '分配权限', '/roles/saveRoleResources', '2', '3', '12');
4647

4748
-- ----------------------------
48-
-- Table structure for role
49+
-- Table structure for `role`
4950
-- ----------------------------
5051
DROP TABLE IF EXISTS `role`;
5152
CREATE TABLE `role` (
52-
`id` int(11) NOT NULL AUTO_INCREMENT,
53-
`roleKey` varchar(50) NOT NULL,
54-
`roleDesc` varchar(255) DEFAULT NULL,
55-
PRIMARY KEY (`id`)
56-
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8;
53+
`id` int(11) NOT NULL auto_increment,
54+
`roleDesc` varchar(255) default NULL,
55+
PRIMARY KEY (`id`)
56+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
5757

5858
-- ----------------------------
5959
-- Records of role
6060
-- ----------------------------
61-
INSERT INTO `role` VALUES ('1', 'ADMIN', '管理员');
62-
INSERT INTO `role` VALUES ('2', 'MEMBER', '普通用户');
63-
INSERT INTO `role` VALUES ('3', 'SUPER', '超级管理员');
61+
INSERT INTO `role` VALUES ('1', '管理员');
62+
INSERT INTO `role` VALUES ('2', '普通用户');
63+
INSERT INTO `role` VALUES ('3', '超级管理员');
6464

6565
-- ----------------------------
66-
-- Table structure for role_resources
66+
-- Table structure for `role_resources`
6767
-- ----------------------------
6868
DROP TABLE IF EXISTS `role_resources`;
6969
CREATE TABLE `role_resources` (
7070
`roleId` int(11) NOT NULL,
7171
`resourcesId` int(11) NOT NULL,
72-
PRIMARY KEY (`roleId`,`resourcesId`)
72+
PRIMARY KEY (`roleId`,`resourcesId`)
7373
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
7474

7575
-- ----------------------------
@@ -84,29 +84,39 @@ INSERT INTO `role_resources` VALUES ('1', '7');
8484
INSERT INTO `role_resources` VALUES ('1', '8');
8585
INSERT INTO `role_resources` VALUES ('1', '9');
8686
INSERT INTO `role_resources` VALUES ('1', '10');
87+
INSERT INTO `role_resources` VALUES ('1', '11');
88+
INSERT INTO `role_resources` VALUES ('1', '13');
89+
INSERT INTO `role_resources` VALUES ('2', '2');
90+
INSERT INTO `role_resources` VALUES ('2', '3');
91+
INSERT INTO `role_resources` VALUES ('2', '4');
92+
INSERT INTO `role_resources` VALUES ('2', '9');
8793
INSERT INTO `role_resources` VALUES ('3', '2');
8894
INSERT INTO `role_resources` VALUES ('3', '3');
95+
INSERT INTO `role_resources` VALUES ('3', '4');
8996
INSERT INTO `role_resources` VALUES ('3', '5');
97+
INSERT INTO `role_resources` VALUES ('3', '7');
98+
INSERT INTO `role_resources` VALUES ('3', '8');
99+
INSERT INTO `role_resources` VALUES ('3', '9');
90100
INSERT INTO `role_resources` VALUES ('3', '10');
91101
INSERT INTO `role_resources` VALUES ('9', '9');
92102

93103
-- ----------------------------
94-
-- Table structure for user
104+
-- Table structure for `user`
95105
-- ----------------------------
96106
DROP TABLE IF EXISTS `user`;
97107
CREATE TABLE `user` (
98-
`id` int(11) NOT NULL AUTO_INCREMENT,
99-
`username` varchar(33) DEFAULT NULL,
100-
`password` varchar(33) DEFAULT NULL,
101-
`enable` int(10) DEFAULT '1' COMMENT '是否启用',
102-
PRIMARY KEY (`id`)
103-
) ENGINE=InnoDB AUTO_INCREMENT=22DEFAULT CHARSET=utf8;
108+
`id` int(11) NOT NULL auto_increment,
109+
`username` varchar(33) default NULL,
110+
`password` varchar(33) default NULL,
111+
`enable` int(10) default '1' COMMENT '是否启用',
112+
PRIMARY KEY (`id`)
113+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
104114

105115
-- ----------------------------
106116
-- Records of user
107117
-- ----------------------------
108-
INSERT INTO `user` VALUES ('1', 'admin', '21232f297a57a5a743894a0e4a801fc3', '1');
109-
INSERT INTO `user` VALUES ('2', 'user1', 'user1', '1');
118+
INSERT INTO `user` VALUES ('1', 'admin', '3ef7164d1f6167cb9f2658c07d3c2f0a', '1');
119+
INSERT INTO `user` VALUES ('2', 'user1', '90e66e36e3135a91d298177d4389851e', '1');
110120
INSERT INTO `user` VALUES ('3', 'user2', '121', '0');
111121
INSERT INTO `user` VALUES ('4', 'user3', 'user3', '1');
112122
INSERT INTO `user` VALUES ('5', 'user4', 'user4', '1');
@@ -124,20 +134,93 @@ INSERT INTO `user` VALUES ('16', 'user15', 'user15', '1');
124134
INSERT INTO `user` VALUES ('17', 'user16', 'user16', '1');
125135
INSERT INTO `user` VALUES ('18', 'user17', 'user17', '1');
126136
INSERT INTO `user` VALUES ('19', 'user18', 'user18', '1');
127-
INSERT INTO `user` VALUES ('20', 'user19', 'user19', '1');
128137
INSERT INTO `user` VALUES ('21', 'user20', 'user20', '1');
129138

130139
-- ----------------------------
131-
-- Table structure for user_role
140+
-- Table structure for `user_role`
132141
-- ----------------------------
133142
DROP TABLE IF EXISTS `user_role`;
134143
CREATE TABLE `user_role` (
135-
`userId` int(11) DEFAULT NULL,
136-
`roleId` int(11) DEFAULT NULL
144+
`userId` int(11) default NULL,
145+
`roleId` int(11) default NULL
137146
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
138147

139148
-- ----------------------------
140149
-- Records of user_role
141150
-- ----------------------------
151+
INSERT INTO `user_role` VALUES ('23', '2');
142152
INSERT INTO `user_role` VALUES ('1', '1');
143-
INSERT INTO `user_role` VALUES ('2', '3');
153+
INSERT INTO `user_role` VALUES ('2', '2');
154+
155+
-- ----------------------------
156+
-- Procedure structure for `init_shiro_demo`
157+
-- ----------------------------
158+
DROP PROCEDURE IF EXISTS `init_shiro_demo`;
159+
DELIMITER ;;
160+
CREATE DEFINER=`root`@`%` PROCEDURE `init_shiro_demo`()
161+
BEGIN
162+
/*
163+
SQLyog 企业版 - MySQL GUI v7.14
164+
MySQL - 5.6.16-log : Database -
165+
*********************************************************************
166+
*/
167+
/*表结构插入*/
168+
DROP TABLE IF EXISTS `u_permission`;
169+
CREATE TABLE `u_permission` (
170+
`id` bigint(20) NOT NULL AUTO_INCREMENT,
171+
`url` varchar(256) DEFAULT NULL COMMENT 'url地址',
172+
`name` varchar(64) DEFAULT NULL COMMENT 'url描述',
173+
PRIMARY KEY (`id`)
174+
) ENGINE=InnoDB AUTO_INCREMENT=21 DEFAULT CHARSET=utf8;
175+
/*Table structure for table `u_role` */
176+
DROP TABLE IF EXISTS `u_role`;
177+
CREATE TABLE `u_role` (
178+
`id` bigint(20) NOT NULL AUTO_INCREMENT,
179+
`name` varchar(32) DEFAULT NULL COMMENT '角色名称',
180+
`type` varchar(10) DEFAULT NULL COMMENT '角色类型',
181+
PRIMARY KEY (`id`)
182+
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8;
183+
/*Table structure for table `u_role_permission` */
184+
DROP TABLE IF EXISTS `u_role_permission`;
185+
CREATE TABLE `u_role_permission` (
186+
`rid` bigint(20) DEFAULT NULL COMMENT '角色ID',
187+
`pid` bigint(20) DEFAULT NULL COMMENT '权限ID'
188+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
189+
/*Table structure for table `u_user` */
190+
DROP TABLE IF EXISTS `u_user`;
191+
CREATE TABLE `u_user` (
192+
`id` bigint(20) NOT NULL AUTO_INCREMENT,
193+
`nickname` varchar(20) DEFAULT NULL COMMENT '用户昵称',
194+
`email` varchar(128) DEFAULT NULL COMMENT '邮箱|登录帐号',
195+
`pswd` varchar(32) DEFAULT NULL COMMENT '密码',
196+
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
197+
`last_login_time` datetime DEFAULT NULL COMMENT '最后登录时间',
198+
`status` bigint(1) DEFAULT '1' COMMENT '1:有效,0:禁止登录',
199+
PRIMARY KEY (`id`)
200+
) ENGINE=InnoDB AUTO_INCREMENT=15 DEFAULT CHARSET=utf8;
201+
/*Table structure for table `u_user_role` */
202+
DROP TABLE IF EXISTS `u_user_role`;
203+
CREATE TABLE `u_user_role` (
204+
`uid` bigint(20) DEFAULT NULL COMMENT '用户ID',
205+
`rid` bigint(20) DEFAULT NULL COMMENT '角色ID'
206+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
207+
/*
208+
SQLyog 企业版 - MySQL GUI v7.14
209+
MySQL - 5.6.16-log : Database - i_wenyiba_com
210+
*********************************************************************
211+
*/
212+
/*所有的表数据插入*/
213+
/*Data for the table `u_permission` */
214+
insert into `u_permission`(`id`,`url`,`name`) values (4,'/permission/index.shtml','权限列表'),(6,'/permission/addPermission.shtml','权限添加'),(7,'/permission/deletePermissionById.shtml','权限删除'),(8,'/member/list.shtml','用户列表'),(9,'/member/online.shtml','在线用户'),(10,'/member/changeSessionStatus.shtml','用户Session踢出'),(11,'/member/forbidUserById.shtml','用户激活&禁止'),(12,'/member/deleteUserById.shtml','用户删除'),(13,'/permission/addPermission2Role.shtml','权限分配'),(14,'/role/clearRoleByUserIds.shtml','用户角色分配清空'),(15,'/role/addRole2User.shtml','角色分配保存'),(16,'/role/deleteRoleById.shtml','角色列表删除'),(17,'/role/addRole.shtml','角色列表添加'),(18,'/role/index.shtml','角色列表'),(19,'/permission/allocation.shtml','权限分配'),(20,'/role/allocation.shtml','角色分配');
215+
/*Data for the table `u_role` */
216+
insert into `u_role`(`id`,`name`,`type`) values (1,'系统管理员','888888'),(3,'权限角色','100003'),(4,'用户中心','100002');
217+
/*Data for the table `u_role_permission` */
218+
insert into `u_role_permission`(`rid`,`pid`) values (4,8),(4,9),(4,10),(4,11),(4,12),(3,4),(3,6),(3,7),(3,13),(3,14),(3,15),(3,16),(3,17),(3,18),(3,19),(3,20),(1,4),(1,6),(1,7),(1,8),(1,9),(1,10),(1,11),(1,12),(1,13),(1,14),(1,15),(1,16),(1,17),(1,18),(1,19),(1,20);
219+
/*Data for the table `u_user` */
220+
insert into `u_user`(`id`,`nickname`,`email`,`pswd`,`create_time`,`last_login_time`,`status`) values (1,'管理员','admin','9c3250081c7b1f5c6cbb8096e3e1cd04','2016年06月16日 11:15:33','2016年06月16日 11:24:10',1),(11,'soso','8446666@qq.com','d57ffbe486910dd5b26d0167d034f9ad','2016年05月26日 20:50:54','2016年06月16日 11:24:35',1),(12,'8446666','8446666','4afdc875a67a55528c224ce088be2ab8','2016年05月27日 22:34:19','2016年06月15日 17:03:16',1);
221+
/*Data for the table `u_user_role` */
222+
insert into `u_user_role`(`uid`,`rid`) values (12,4),(11,3),(11,4),(1,1);
223+
224+
END
225+
;;
226+
DELIMITER ;

‎src/main/resources/templates/helloHtml.html‎

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /