|
@@ -1,5 +1,9 @@
|
|
|
package com.shawn.monitor;
|
|
|
|
|
|
+import com.shawn.model.dto.ResultMessage;
|
|
|
+import com.shawn.model.entity.TAdmin;
|
|
|
+import com.shawn.service.interfac.TAdminServiceInterface;
|
|
|
+import com.shawn.util.JavaWebToken;
|
|
|
import com.shawn.web.exception.MyException;
|
|
|
import lombok.extern.apachecommons.CommonsLog;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
@@ -11,12 +15,14 @@ import org.aspectj.lang.annotation.Around;
|
|
|
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.RequestAttributes;
|
|
|
import org.springframework.web.context.request.RequestContextHolder;
|
|
|
import org.springframework.web.context.request.ServletRequestAttributes;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
+import java.util.Map;
|
|
|
|
|
|
/**
|
|
|
* @author 吴洪双
|
|
@@ -26,6 +32,8 @@ import javax.servlet.http.HttpServletRequest;
|
|
|
@Component
|
|
|
public class PerformanceMonitor {
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private TAdminServiceInterface tAdminService;
|
|
|
/**
|
|
|
* 所有请求,
|
|
|
* 排除了登录
|
|
@@ -44,10 +52,21 @@ public class PerformanceMonitor {
|
|
|
if(StringUtils.isEmpty(token)){
|
|
|
// TODO 做token的逻辑判断
|
|
|
isLogin = false;
|
|
|
+ }else{
|
|
|
+ Map<String, Object> map = JavaWebToken.parserJavaWebToken(token);
|
|
|
+ Object userId = map.get("userId");
|
|
|
+ Long id = Long.valueOf(String.valueOf(userId));
|
|
|
+ TAdmin admin = tAdminService.selectEntityById(id);
|
|
|
+ if(admin!=null){
|
|
|
+ isLogin = true;
|
|
|
+ }else {
|
|
|
+ isLogin = false;
|
|
|
+ }
|
|
|
}
|
|
|
if(!isLogin){
|
|
|
throw new MyException("请登录");
|
|
|
}
|
|
|
+// throw new MyException("请登录");
|
|
|
}
|
|
|
|
|
|
}
|