|
|
|
@ -60,13 +60,13 @@ public class AdminCheckAuthorityAspect {
|
|
|
|
|
HttpServletRequest request = attributes.getRequest();
|
|
|
|
|
|
|
|
|
|
//获取当前用户的信息
|
|
|
|
|
String tokenId = request.getHeader("token");
|
|
|
|
|
String tokenId = request.getHeader("admin-token");
|
|
|
|
|
Integer id = Integer.valueOf(new JwtUtil().parseAdminJWT(tokenId).getId());
|
|
|
|
|
|
|
|
|
|
Admin admin = adminService.getById(id);
|
|
|
|
|
//1、查询【当前用户】所拥有的【角色】
|
|
|
|
|
String roleIdsStr = admin.getRoleIds();
|
|
|
|
|
if (roleIdsStr != null && !roleIdsStr.trim().equals("")){
|
|
|
|
|
if (roleIdsStr != null && !roleIdsStr.trim().equals("")) {
|
|
|
|
|
String[] roleIds = roleIdsStr.split(",");
|
|
|
|
|
|
|
|
|
|
HashSet<Integer> jurisdictionIds = new HashSet<>();
|
|
|
|
@ -83,13 +83,15 @@ public class AdminCheckAuthorityAspect {
|
|
|
|
|
MethodSignature signature = (MethodSignature) joinPoint.getSignature();
|
|
|
|
|
AdminTokenValid annotation = signature.getMethod().getAnnotation(AdminTokenValid.class);
|
|
|
|
|
String jurisdictionId = annotation.jurisdictionId();
|
|
|
|
|
|
|
|
|
|
//5、判断该用户是否存在该api所需权限,如果存在,则通过,不存在则抛出提示权限不足
|
|
|
|
|
if (!jurisdictionIds.contains(Integer.valueOf(jurisdictionId))){
|
|
|
|
|
throw new BizException(HttpStatusEnum.CUSTOM_EXCEPTION,"用户权限不足");
|
|
|
|
|
if (!jurisdictionId.equals("")) {
|
|
|
|
|
//5、判断该用户是否存在该api所需权限,如果存在,则通过,不存在则抛出提示权限不足
|
|
|
|
|
if (!jurisdictionIds.contains(Integer.valueOf(jurisdictionId))) {
|
|
|
|
|
throw new BizException(HttpStatusEnum.CUSTOM_EXCEPTION, "用户权限不足");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}else {
|
|
|
|
|
throw new BizException(HttpStatusEnum.CUSTOM_EXCEPTION,"用户权限不足");
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
throw new BizException(HttpStatusEnum.CUSTOM_EXCEPTION, "用户权限不足");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
@ -103,5 +105,4 @@ public class AdminCheckAuthorityAspect {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|