LoginHistoryAspect.java
2.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
package com.lhcredit.framework.aspectj;//package com.lhcredit.framework.aspectj;
//
//import com.lhcredit.framework.aspectj.lang.annotation.LoginHistoryArr;
//import com.lhcredit.framework.web.domain.AjaxResult;
//import com.lhcredit.framework.web.domain.TokenEntity;
//import com.lhcredit.framework.web.service.TokenManager;
//import com.lhcredit.project.business.loginHistory.domain.LoginHistory;
//import com.lhcredit.project.business.loginHistory.service.ILoginHistoryService;
//import com.lhcredit.project.front.frontUser.domain.FrontUser;
//import org.aspectj.lang.JoinPoint;
//import org.aspectj.lang.ProceedingJoinPoint;
//import org.aspectj.lang.Signature;
//import org.aspectj.lang.annotation.After;
//import org.aspectj.lang.annotation.Around;
//import org.aspectj.lang.annotation.Aspect;
//import org.aspectj.lang.annotation.Pointcut;
//import org.aspectj.lang.reflect.MethodSignature;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Component;
//
//import java.lang.reflect.Method;
//import java.util.Date;
//
//@Aspect
//@Component
//public class LoginHistoryAspect {
// @Autowired
// private ILoginHistoryService loginHistoryService;
// @Autowired
// private TokenManager tokenManager;
//
// // 配置织入点
// @Pointcut("@annotation(com.lhcredit.framework.aspectj.lang.annotation.LoginHistoryArr)")
// public void LoginPointCut() {
//
// }
//
// @Around("LoginPointCut()")
// public Object d(ProceedingJoinPoint point) throws Throwable {
// AjaxResult res=new AjaxResult(AjaxResult.Type.ERROR,"登录失败");
// try {
// res =(AjaxResult)point.proceed();
// int code = (int)res.get("code");
// if(2000 == code){
// FrontUser user = (FrontUser)res.get("data");
// LoginHistory loginHistory = new LoginHistory();
// if (null != user) {
// loginHistory.setUserId(user.getUserId());
// loginHistory.setStatus("0");
// loginHistory.setDelFlag("0");
// loginHistory.setLastLoginTime((new Date()));
// loginHistory.setUpdateTime(new Date());
// loginHistory.setCreateTime(new Date());
// loginHistoryService.insertLoginHistory(loginHistory);
// }
// }
// } catch (Throwable throwable) {
// throwable.printStackTrace();
// }
//
// return res;
// }
//
//
//
// /**
// * 是否存在注解,如果存在就获取
// */
// private LoginHistoryArr getAnnotationLog(JoinPoint joinPoint) {
// Signature signature = joinPoint.getSignature();
// MethodSignature methodSignature = (MethodSignature) signature;
// Method method = methodSignature.getMethod();
//
// if (method != null) {
// return method.getAnnotation(LoginHistoryArr.class);
// }
// return null;
// }
//
//}