|
@@ -1,63 +1,67 @@
|
|
|
-package com.fdkankan.jp.xspace.interceptor;
|
|
|
-
|
|
|
-import com.fdkankan.common.util.JwtUtil;
|
|
|
-import com.fdkankan.jp.xspace.common.ResultCode;
|
|
|
-import com.fdkankan.jp.xspace.common.exception.BusinessException;
|
|
|
-import com.fdkankan.jp.xspace.entity.User;
|
|
|
-import com.fdkankan.jp.xspace.service.IUserRoleService;
|
|
|
-import com.fdkankan.jp.xspace.service.IUserService;
|
|
|
-import lombok.extern.log4j.Log4j2;
|
|
|
-import org.apache.commons.lang3.StringUtils;
|
|
|
-import org.aspectj.lang.JoinPoint;
|
|
|
-import org.aspectj.lang.annotation.Aspect;
|
|
|
-import org.aspectj.lang.annotation.Before;
|
|
|
-import org.aspectj.lang.annotation.Pointcut;
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.stereotype.Component;
|
|
|
-import org.springframework.web.context.request.RequestContextHolder;
|
|
|
-import org.springframework.web.context.request.ServletRequestAttributes;
|
|
|
-
|
|
|
-import javax.servlet.http.HttpServletRequest;
|
|
|
-import java.io.IOException;
|
|
|
-import java.util.Set;
|
|
|
-
|
|
|
-@Log4j2
|
|
|
-@Aspect
|
|
|
-@Component
|
|
|
-public class CheckPlatAdminPermitAspect {
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private IUserService userService;
|
|
|
- @Autowired
|
|
|
- private IUserRoleService userRoleService;
|
|
|
-
|
|
|
- @Pointcut("@annotation(com.fdkankan.jp.xspace.common.annotation.CheckPlatformAdminPermit)")
|
|
|
- public void CheckPlatformAdminPermit() {
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 前置通知 用于判断用户协作场景是否有协作权限
|
|
|
- *
|
|
|
- * @param joinPoint
|
|
|
- * 切点
|
|
|
- * @throws IOException
|
|
|
- */
|
|
|
- @Before("CheckPlatformAdminPermit()")
|
|
|
- public void doBefore(JoinPoint joinPoint) throws Exception {
|
|
|
- HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
|
|
|
- String token = request.getHeader("token");
|
|
|
- String username = JwtUtil.getUsername(token);
|
|
|
- if(StringUtils.isBlank(username)){
|
|
|
- throw new BusinessException(ResultCode.USER_NOT_LOGIN);
|
|
|
- }
|
|
|
- User user = userService.getByUserName(username);
|
|
|
- if(user == null){
|
|
|
- throw new BusinessException(ResultCode.USER_NOT_LOGIN);
|
|
|
- }
|
|
|
- Set<Long> roleIds = userRoleService.getByUser(user);
|
|
|
- if(!roleIds.contains(5L)){
|
|
|
- throw new BusinessException(ResultCode.NOT_PERMISSION);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-}
|
|
|
+//package com.fdkankan.jp.xspace.interceptor;
|
|
|
+//
|
|
|
+//import com.fdkankan.common.util.JwtUtil;
|
|
|
+//import com.fdkankan.jp.xspace.common.ResultCode;
|
|
|
+//import com.fdkankan.jp.xspace.common.exception.BusinessException;
|
|
|
+//import com.fdkankan.jp.xspace.entity.SysUser;
|
|
|
+//import com.fdkankan.jp.xspace.entity.User;
|
|
|
+//import com.fdkankan.jp.xspace.service.ISysUserService;
|
|
|
+//import com.fdkankan.jp.xspace.service.IUserRoleService;
|
|
|
+//import com.fdkankan.jp.xspace.service.IUserService;
|
|
|
+//import lombok.extern.log4j.Log4j2;
|
|
|
+//import org.apache.commons.lang3.StringUtils;
|
|
|
+//import org.aspectj.lang.JoinPoint;
|
|
|
+//import org.aspectj.lang.annotation.Aspect;
|
|
|
+//import org.aspectj.lang.annotation.Before;
|
|
|
+//import org.aspectj.lang.annotation.Pointcut;
|
|
|
+//import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+//import org.springframework.stereotype.Component;
|
|
|
+//import org.springframework.web.context.request.RequestContextHolder;
|
|
|
+//import org.springframework.web.context.request.ServletRequestAttributes;
|
|
|
+//
|
|
|
+//import javax.servlet.http.HttpServletRequest;
|
|
|
+//import java.io.IOException;
|
|
|
+//import java.util.Set;
|
|
|
+//
|
|
|
+//@Log4j2
|
|
|
+//@Aspect
|
|
|
+//@Component
|
|
|
+//public class CheckPlatAdminPermitAspect {
|
|
|
+//
|
|
|
+// @Autowired
|
|
|
+// private IUserService userService;
|
|
|
+// @Autowired
|
|
|
+// private IUserRoleService userRoleService;
|
|
|
+// @Autowired
|
|
|
+// private ISysUserService sysUserService;
|
|
|
+//
|
|
|
+// @Pointcut("@annotation(com.fdkankan.jp.xspace.common.annotation.CheckPlatformAdminPermit)")
|
|
|
+// public void CheckPlatformAdminPermit() {
|
|
|
+// }
|
|
|
+//
|
|
|
+// /**
|
|
|
+// * 前置通知 用于判断用户协作场景是否有协作权限
|
|
|
+// *
|
|
|
+// * @param joinPoint
|
|
|
+// * 切点
|
|
|
+// * @throws IOException
|
|
|
+// */
|
|
|
+// @Before("CheckPlatformAdminPermit()")
|
|
|
+// public void doBefore(JoinPoint joinPoint) throws Exception {
|
|
|
+// HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
|
|
|
+// String token = request.getHeader("token");
|
|
|
+// String username = JwtUtil.getUsername(token);
|
|
|
+// if(StringUtils.isBlank(username)){
|
|
|
+// throw new BusinessException(ResultCode.USER_NOT_LOGIN);
|
|
|
+// }
|
|
|
+// SysUser user = sysUserService.getByUserName(username);
|
|
|
+// if(user == null){
|
|
|
+// throw new BusinessException(ResultCode.USER_NOT_LOGIN);
|
|
|
+// }
|
|
|
+// Set<Long> roleIds = userRoleService.getByUser(user);
|
|
|
+// if(!roleIds.contains(5L)){
|
|
|
+// throw new BusinessException(ResultCode.NOT_PERMISSION);
|
|
|
+// }
|
|
|
+// }
|
|
|
+//
|
|
|
+//}
|