|
@@ -7,7 +7,9 @@ import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.example.xiaoshiweixinback.business.common.Response;
|
|
|
import com.example.xiaoshiweixinback.business.utils.CacheUtil;
|
|
|
+import com.example.xiaoshiweixinback.business.utils.JsonUtils;
|
|
|
import com.example.xiaoshiweixinback.business.utils.LoginUtils;
|
|
|
+import com.example.xiaoshiweixinback.business.utils.RedisUtil;
|
|
|
import com.example.xiaoshiweixinback.entity.vo.PersonnelVO;
|
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
|
import org.aspectj.lang.JoinPoint;
|
|
@@ -22,6 +24,7 @@ import javax.script.ScriptEngine;
|
|
|
import javax.script.ScriptEngineManager;
|
|
|
import java.lang.reflect.Method;
|
|
|
import java.util.List;
|
|
|
+import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
@Order(2)
|
|
|
@Aspect
|
|
@@ -29,6 +32,8 @@ import java.util.List;
|
|
|
public class CheckLoginAop {
|
|
|
@Autowired
|
|
|
private CacheUtil cacheUtil;
|
|
|
+ @Autowired
|
|
|
+ private RedisUtil redisUtil;
|
|
|
|
|
|
/**
|
|
|
* 定义切点
|
|
@@ -52,11 +57,12 @@ public class CheckLoginAop {
|
|
|
public Object doAround(ProceedingJoinPoint joinPoint) throws Throwable {
|
|
|
// 是否通过切面过滤标记
|
|
|
Boolean isPass = true;
|
|
|
- try { cacheUtil.getLoginUser(LoginUtils.getToken());
|
|
|
- }
|
|
|
- catch (Exception e){
|
|
|
+ try {
|
|
|
+ PersonnelVO personnelVO = cacheUtil.getLoginUser(LoginUtils.getToken());
|
|
|
+ redisUtil.setEx(LoginUtils.getToken(), JsonUtils.objectToJson(personnelVO), 3L, TimeUnit.HOURS);
|
|
|
+ } catch (Exception e) {
|
|
|
return Response.unLogin("未登录");
|
|
|
- }
|
|
|
+ }
|
|
|
//判断不通过
|
|
|
if (!isPass) {
|
|
|
return Response.unLogin("未登录");
|