菜单鉴权,网页下拉不鉴权
This commit is contained in:
parent
15c1a7e89a
commit
ec2e96236b
|
|
@ -57,6 +57,11 @@ public class SysDic extends BaseEntity {
|
|||
*/
|
||||
private String level;
|
||||
|
||||
/**
|
||||
* o/null: 默认,需要鉴权, 1: 跳过鉴权
|
||||
*/
|
||||
private Integer skipPermission;
|
||||
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
|
|
@ -159,6 +164,14 @@ public class SysDic extends BaseEntity {
|
|||
return creator;
|
||||
}
|
||||
|
||||
public Integer getSkipPermission() {
|
||||
return skipPermission;
|
||||
}
|
||||
|
||||
public void setSkipPermission(Integer skipPermission) {
|
||||
this.skipPermission = skipPermission;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
|
||||
|
|
|
|||
|
|
@ -2,6 +2,10 @@ package com.bonus.sgzb.common.security.aspect;
|
|||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import cn.hutool.json.JSONArray;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.bonus.sgzb.common.security.auth.AuthUtil;
|
||||
import com.bonus.sgzb.common.security.annotation.RequiresRoles;
|
||||
import org.aspectj.lang.ProceedingJoinPoint;
|
||||
|
|
@ -54,9 +58,23 @@ public class PreAuthorizeAspect
|
|||
@Around("pointcut()")
|
||||
public Object around(ProceedingJoinPoint joinPoint) throws Throwable
|
||||
{
|
||||
//获取请求参数
|
||||
Object[] args = joinPoint.getArgs();
|
||||
String argStr = JSON.toJSONString(args);
|
||||
JSONArray jsonArray = JSONUtil.parseArray(argStr);
|
||||
boolean needPermission = true;
|
||||
for (int i = 0; i < jsonArray.size(); i++) {
|
||||
JSONObject jsonObject = jsonArray.getJSONObject(i);
|
||||
if ("1".equals(jsonObject.getStr("skipPermission"))) {
|
||||
needPermission = false;
|
||||
}
|
||||
}
|
||||
|
||||
// 注解鉴权
|
||||
if (needPermission) {
|
||||
MethodSignature signature = (MethodSignature) joinPoint.getSignature();
|
||||
checkMethodAnnotation(signature.getMethod());
|
||||
}
|
||||
try
|
||||
{
|
||||
// 执行原有逻辑
|
||||
|
|
|
|||
Loading…
Reference in New Issue