|
@@ -0,0 +1,37 @@
|
|
|
+package com.idea.pro.service;
|
|
|
+
|
|
|
+import com.rockstar.shiro.util.ShiroUtils;
|
|
|
+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.stereotype.Component;
|
|
|
+import org.springframework.web.context.request.RequestContextHolder;
|
|
|
+import org.springframework.web.context.request.ServletRequestAttributes;
|
|
|
+
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
+
|
|
|
+@Aspect
|
|
|
+@Component
|
|
|
+public class HttpRequestAopFilter {
|
|
|
+
|
|
|
+ @Pointcut("execution(* com.*.*.controller.*.*(..))")
|
|
|
+ public void ouAspect() {
|
|
|
+ }
|
|
|
+
|
|
|
+ @Before("ouAspect()")
|
|
|
+ public void beforeMethod(JoinPoint joinPoint) throws Exception {
|
|
|
+ ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
|
|
|
+ HttpServletRequest request = attributes.getRequest();
|
|
|
+ String uri = request.getServletPath();
|
|
|
+ if(uri.contains("LogController")){
|
|
|
+ if(null != ShiroUtils.getUser()){
|
|
|
+ if(!"1".equals(ShiroUtils.getUserId())){
|
|
|
+ throw new Exception("该接口没有访问权限!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+}
|