Skip to content

Commit cbeb397

Browse files
committed
权限注解 扩展访问控制简单实现
1 parent 7842c60 commit cbeb397

19 files changed

Lines changed: 104 additions & 136 deletions

File tree

README.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
# gradleInitProDemo
22
gradle初始项目demo,jetty简单main运行项目
33

4+
###吼吼 啊!终于架子搭起来了,发张效果图看看,......
5+
###一天一点,神功修练中....
46

5-
吼吼 啊!终于架子搭起来了,发张效果图看看,......html页面框架是借用以前公司的,额对前端不是很精通,选抄过来了。
6-
7-
![图1](/doc/imgEffect/20160520174203.png)
7+
![图1](/doc/imgEffect/20160609145114.png)
88
![图2](/doc/imgEffect/20160607140339.png)
9-
![图3](/doc/imgEffect/20160607140425.png)
9+
![图3](/doc/imgEffect/20160609145311.png)
10+
![图3](/doc/imgEffect/20160609145345.png)
11+
![图3](/doc/imgEffect/20160609153358.png)
1012

11-
一天一点,神功修练中....

doc/imgEffect/20160520174203.png

-186 KB
Binary file not shown.

doc/imgEffect/20160607140425.png

-134 KB
Binary file not shown.

doc/imgEffect/20160609145114.png

294 KB
Loading

doc/imgEffect/20160609145311.png

181 KB
Loading

doc/imgEffect/20160609145345.png

201 KB
Loading

doc/imgEffect/20160609153358.png

215 KB
Loading

src/main/java/com/rui/pro1/common/annotatiions/PermissionAnnot.java

Lines changed: 31 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,31 +5,45 @@
55
import java.lang.annotation.Retention;
66
import java.lang.annotation.RetentionPolicy;
77
import java.lang.annotation.Target;
8+
import org.apache.shiro.authz.annotation.RequiresPermissions;
89

9-
import org.apache.shiro.authz.annotation.Logical;
10+
/**
11+
* 简单实现权限,扫描到DB和访问控制<br/>
12+
* 如果要实现复杂权限控和角色等等<br/>
13+
* 请使用shiro内置权限控制注解<br/>
14+
* {@link RequiresPermissions}
15+
* @author rui
16+
* @date 2016/06/09
17+
*
18+
*/
1019

1120
@Target(ElementType.METHOD)
1221
@Retention(RetentionPolicy.RUNTIME)
1322
@Documented
14-
//@Inherited
15-
public @interface PermissionAnnot
16-
{
23+
// @Inherited
24+
public @interface PermissionAnnot {
1725
public String id() default "-1";
18-
//public String menuId() default "-1";
26+
27+
// public String menuId() default "-1";
1928
public String name() default "";
29+
2030
public String cls() default "";
31+
2132
public int order() default -1;
22-
23-
/**
24-
* The permission string which will be passed to {@link org.apache.shiro.subject.Subject#isPermitted(String)}
25-
* to determine if the user is allowed to invoke the code protected by this annotation.
26-
*/
27-
// String[] value();
28-
29-
/**
30-
* The logical operation for the permission checks in case multiple roles are specified. AND is the default
31-
* @since 1.1.0
32-
*/
33-
//Logical logical() default Logical.AND;
33+
34+
/**
35+
* The permission string which will be passed to
36+
* {@link org.apache.shiro.subject.Subject#isPermitted(String)} to determine
37+
* if the user is allowed to invoke the code protected by this annotation.
38+
*/
39+
// String[] value();
40+
41+
/**
42+
* The logical operation for the permission checks in case multiple roles
43+
* are specified. AND is the default
44+
*
45+
* @since 1.1.0
46+
*/
47+
// Logical logical() default Logical.AND;
3448

3549
}

src/main/java/com/rui/pro1/modules/setting/web/PersonalController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public ResultBean updatePassword(HttpServletRequest request, HttpServletResponse
9898
}
9999

100100
String srcPassowrdEncrypt = PassUtil.encryptPassword(
101-
user.getUserName(), srcPassword);
101+
srcPassword, user.getUserName());
102102

103103
if (!user.getPassword().equals(srcPassowrdEncrypt)) {
104104
rb = new ResultBean(false, MessageCode.USER_SRC_PASSWORD_ERROR,

src/main/java/com/rui/pro1/modules/sys/service/IUserService.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,13 @@ public interface IUserService {
2525
int add(User user) throws Exception;
2626

2727
int update(User user);
28-
28+
2929
UserBean getUser(String username);
30-
30+
3131
Set<String> getUserRole(String username);
3232

3333
Set<String> getUserPermissions(String username);
34-
35-
List<Menu> getUserMenus(String username);
36-
3734

35+
List<Menu> getUserMenus(String username);
3836

3937
}

0 commit comments

Comments
 (0)