月球大数据地理空间分析展示平台-【后端】-月球后台服务
1
13693261870
2024-11-11 fee67ca8a0760315047a52fc4101a8f4f80b7a7f
src/main/java/com/moon/server/aspect/LogAspect.java
@@ -23,12 +23,9 @@
import java.lang.reflect.Method;
import java.util.TimerTask;
/**
 * 日志切面类
 * @author WWW
 */
@Aspect
@Component
@SuppressWarnings("ALL")
public class LogAspect {
    @Autowired
    private TokenService tokenService;
@@ -58,27 +55,21 @@
    }
    /**
     * 环绕通知 @Around,也可以使用 @Before (前置通知) 或 @After (后置通知)
     * @Around,@Before,@After
     */
    @Around("logPointCut()")
    public Object around(ProceedingJoinPoint point) throws Throwable {
        long beginTime = System.currentTimeMillis();
        // 执行方法
        Object result = point.proceed();
        // 执行时长(毫秒)
        long time = System.currentTimeMillis() - beginTime;
        // 保存日志
        saveLog(point, time);
        return result;
    }
    /**
     * 保存日志
     */
    private void saveLog(ProceedingJoinPoint joinPoint, long time) {
        try {
            MethodSignature signature = (MethodSignature) joinPoint.getSignature();
@@ -93,7 +84,6 @@
            oe.setUrl(url);
            oe.setExec(time);
            // 设置模块
            Api api = clazz.getAnnotation(Api.class);
            if (api != null) {
                String[] strs = api.tags()[0].split(StaticData.BACKSLASH);
@@ -101,11 +91,9 @@
                oe.setModular2(strs[1]);
            }
            // 设置类名\方法名、类别
            oe.setClazz(clazz.getName() + "." + method.getName());
            oe.setType(getType(method.getName()));
            // 设置备注
            SysLog sysLog = method.getAnnotation(SysLog.class);
            if (sysLog != null) {
                oe.setBak(sysLog.value());
@@ -129,9 +117,6 @@
        }
    }
    /**
     * 获取操作类型
     */
    private static int getType(String methodName) {
        if (methodName.contains(SELECT)) {
            return 1;