更新readme
This commit is contained in:
parent
def0299d85
commit
66d59e4091
|
|
@ -9,8 +9,9 @@ PS:因为喜欢刀锋战士所以取名了SpringBlade,当中有一个类也命
|
||||||
2.[eova](http://www.oschina.net/p/eova)
|
2.[eova](http://www.oschina.net/p/eova)
|
||||||
3.[hutool](http://www.oschina.net/p/hutool)
|
3.[hutool](http://www.oschina.net/p/hutool)
|
||||||
4.[beetl](http://www.oschina.net/p/beetl)
|
4.[beetl](http://www.oschina.net/p/beetl)
|
||||||
|
4.[beetlsql](http://www.oschina.net/p/beetlsql)
|
||||||
5.[dreamlu](http://www.oschina.net/p/dreamlu)
|
5.[dreamlu](http://www.oschina.net/p/dreamlu)
|
||||||
6.[kisso](https://git.oschina.net/baomidou/kisso)
|
6.[kisso](http://www.oschina.net/p/kisso)
|
||||||
|
|
||||||
## 内置功能
|
## 内置功能
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,8 +17,6 @@ package com.smallchill.core.aop;
|
||||||
|
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
|
|
||||||
import org.aspectj.lang.ProceedingJoinPoint;
|
import org.aspectj.lang.ProceedingJoinPoint;
|
||||||
import org.aspectj.lang.annotation.Around;
|
import org.aspectj.lang.annotation.Around;
|
||||||
import org.aspectj.lang.annotation.Aspect;
|
import org.aspectj.lang.annotation.Aspect;
|
||||||
|
|
@ -30,7 +28,6 @@ import com.smallchill.core.annotation.Permission;
|
||||||
import com.smallchill.core.exception.NoPermissionException;
|
import com.smallchill.core.exception.NoPermissionException;
|
||||||
import com.smallchill.core.toolbox.Func;
|
import com.smallchill.core.toolbox.Func;
|
||||||
import com.smallchill.core.toolbox.check.PermissionCheckManager;
|
import com.smallchill.core.toolbox.check.PermissionCheckManager;
|
||||||
import com.smallchill.core.toolbox.kit.HttpKit;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AOP 权限自定义检查
|
* AOP 权限自定义检查
|
||||||
|
|
@ -46,7 +43,6 @@ public class PermissionAop {
|
||||||
|
|
||||||
@Around("cutPermission()")
|
@Around("cutPermission()")
|
||||||
public Object doPermission(ProceedingJoinPoint point) throws Throwable {
|
public Object doPermission(ProceedingJoinPoint point) throws Throwable {
|
||||||
HttpServletRequest request = HttpKit.getRequest();
|
|
||||||
MethodSignature ms = (MethodSignature) point.getSignature();
|
MethodSignature ms = (MethodSignature) point.getSignature();
|
||||||
Method method = ms.getMethod();
|
Method method = ms.getMethod();
|
||||||
Permission permission = method.getAnnotation(Permission.class);
|
Permission permission = method.getAnnotation(Permission.class);
|
||||||
|
|
@ -54,7 +50,7 @@ public class PermissionAop {
|
||||||
if ((permissions.length == 1 && Func.toStr(permissions[0]).equals("ALL"))
|
if ((permissions.length == 1 && Func.toStr(permissions[0]).equals("ALL"))
|
||||||
|| permissions == null || permissions.length == 0) {
|
|| permissions == null || permissions.length == 0) {
|
||||||
//检查全体角色
|
//检查全体角色
|
||||||
boolean result = PermissionCheckManager.checkAll(request);
|
boolean result = PermissionCheckManager.checkAll();
|
||||||
if (result) {
|
if (result) {
|
||||||
return point.proceed();
|
return point.proceed();
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -62,7 +58,7 @@ public class PermissionAop {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
//检查指定角色
|
//检查指定角色
|
||||||
boolean result = PermissionCheckManager.check(permissions, request);
|
boolean result = PermissionCheckManager.check(permissions);
|
||||||
if (result) {
|
if (result) {
|
||||||
return point.proceed();
|
return point.proceed();
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,6 @@
|
||||||
*/
|
*/
|
||||||
package com.smallchill.core.interfaces;
|
package com.smallchill.core.interfaces;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 检查用接口
|
* 检查用接口
|
||||||
|
|
@ -24,16 +23,14 @@ public interface ICheck {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 检查指定角色
|
* 检查指定角色
|
||||||
* @param request
|
* @param permissions
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
boolean check(Object[] permissions, HttpServletRequest request);
|
boolean check(Object[] permissions);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 检查全体角色
|
* 检查全体角色
|
||||||
* @param permissions
|
|
||||||
* @param request
|
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
boolean checkAll(HttpServletRequest request);
|
boolean checkAll();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@ import com.smallchill.core.constant.Cst;
|
||||||
import com.smallchill.core.interfaces.ICheck;
|
import com.smallchill.core.interfaces.ICheck;
|
||||||
import com.smallchill.core.shiro.ShiroKit;
|
import com.smallchill.core.shiro.ShiroKit;
|
||||||
import com.smallchill.core.toolbox.kit.CollectionKit;
|
import com.smallchill.core.toolbox.kit.CollectionKit;
|
||||||
|
import com.smallchill.core.toolbox.kit.HttpKit;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @title 权限自定义检查
|
* @title 权限自定义检查
|
||||||
|
|
@ -33,7 +34,7 @@ import com.smallchill.core.toolbox.kit.CollectionKit;
|
||||||
public class PermissionCheckFactory implements ICheck {
|
public class PermissionCheckFactory implements ICheck {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean check(Object[] permissions, HttpServletRequest request) {
|
public boolean check(Object[] permissions) {
|
||||||
ShiroUser user = ShiroKit.getUser();
|
ShiroUser user = ShiroKit.getUser();
|
||||||
if (null == user) {
|
if (null == user) {
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -46,7 +47,8 @@ public class PermissionCheckFactory implements ICheck {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean checkAll(HttpServletRequest request) {
|
public boolean checkAll() {
|
||||||
|
HttpServletRequest request = HttpKit.getRequest();
|
||||||
ShiroUser user = ShiroKit.getUser();
|
ShiroUser user = ShiroKit.getUser();
|
||||||
if (null == user) {
|
if (null == user) {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
||||||
|
|
@ -15,8 +15,6 @@
|
||||||
*/
|
*/
|
||||||
package com.smallchill.core.toolbox.check;
|
package com.smallchill.core.toolbox.check;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
|
|
||||||
import com.smallchill.core.constant.Cst;
|
import com.smallchill.core.constant.Cst;
|
||||||
import com.smallchill.core.interfaces.ICheck;
|
import com.smallchill.core.interfaces.ICheck;
|
||||||
|
|
||||||
|
|
@ -47,11 +45,11 @@ public class PermissionCheckManager {
|
||||||
this.defaultCheckFactory = defaultCheckFactory;
|
this.defaultCheckFactory = defaultCheckFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean check(Object[] permissions, HttpServletRequest request) {
|
public static boolean check(Object[] permissions) {
|
||||||
return me.defaultCheckFactory.check(permissions, request);
|
return me.defaultCheckFactory.check(permissions);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean checkAll(HttpServletRequest request) {
|
public static boolean checkAll() {
|
||||||
return me.defaultCheckFactory.checkAll(request);
|
return me.defaultCheckFactory.checkAll();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user