管道基础大数据平台系统开发-【后端】-Server
1
13693261870
2022-09-29 0160430ef9b03028e5d1896e17f006f8af0c7daa
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
package com.lf.server.aspect;
 
import org.aspectj.lang.ProceedingJoinPoint;
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.stereotype.Component;
 
import java.lang.reflect.Method;
 
/**
 * 日志切面类
 * @author WWW
 */
@Aspect
@Component
public class LogAspect {
    @Pointcut("")
    public void logPointCut() {
 
    }
 
    @Around("logPointCut()")
    public Object around(ProceedingJoinPoint point) throws Throwable {
        long beginTime = System.currentTimeMillis();
        // 执行方法
        Object result = point.proceed();
 
        // 执行时长(毫秒)
        long time = System.currentTimeMillis() - beginTime;
        // System.out.println("time:"+time)
 
        // 保存日志
        saveLogAction(point, time);
 
        return result;
    }
 
    private void saveLogAction(ProceedingJoinPoint joinPoint, long time) {
        MethodSignature signature = (MethodSignature) joinPoint.getSignature();
        Method method = signature.getMethod();
        /*LogAction logAction = new LogAction();
        com.landtool.lanbase.common.annotation.LogAction log = method.getAnnotation(com.landtool.lanbase.common.annotation.LogAction.class);
        if(log != null){
            // 注解上的描述
            String[] list = log.value().split(",");
            logAction.setLargemodel(list[0]); //大模块
            logAction.setSmallmodel(list[1]);//小模块
            logAction.setRemark(list[2]);    //备注
            logAction.setActiontype(list[3]);//操作类型
 
              //logAction.setRemark(log.value());
              //logAction.setActiontype(log.value());
        }
 
        //获取request
        HttpServletRequest request = HttpContextUtils.getHttpServletRequest();
        String url=request.getServletPath();
        logAction.setRequesturl(url);
        //设置IP地址
        logAction.setRequestip(IPUtils.getIpAddr(request));
 
        //用户名
        Long userid = ((OrgUser) SecurityUtils.getSubject().getPrincipal()).getUserid();
        logAction.setUserid(userid);
 
        logAction.setAppid(loginConfig.getAppId());
 
          //logAction.setLargemodel(loginConfig.getAppFullName());
 
 
 
 
        //保存系统日志
        logActionService.save(logAction);*/
    }
}