merge: 合并冲突解决
This commit is contained in:
@@ -40,8 +40,8 @@
|
|||||||
| 项目类型 | GitCode | Gitee | Github |
|
| 项目类型 | GitCode | Gitee | Github |
|
||||||
|--------|----------------------------------|-----------------------------------------------------------------------|------------------------------------------------------------------------|
|
|--------|----------------------------------|-----------------------------------------------------------------------|------------------------------------------------------------------------|
|
||||||
| 后端 | [youlai-boot](https://gitcode.com/youlai/youlai-boot) | [youlai-boot](https://gitee.com/youlaiorg/youlai-boot) | [youlai-boot](https://gitee.com/haoxianrui/youlai-boot) |
|
| 后端 | [youlai-boot](https://gitcode.com/youlai/youlai-boot) | [youlai-boot](https://gitee.com/youlaiorg/youlai-boot) | [youlai-boot](https://gitee.com/haoxianrui/youlai-boot) |
|
||||||
| 前端 | [vue3-element-admin](https://gitcode.com/youlai/vue3-element-admin) | [vue3-element-admin](https://gitee.com/youlai/vue3-element-admin) | [vue3-element-admin](https://github.com/youlaitech/vue3-element-admin) |
|
| 前端 | [vue3-element-admin](https://gitcode.com/youlai/vue3-element-admin) | [vue3-element-admin](https://gitee.com/youlaiorg/vue3-element-admin) | [vue3-element-admin](https://github.com/youlaitech/vue3-element-admin) |
|
||||||
| 移动端 | [vue-uniapp-template](https://gitcode.com/youlai/vue-uniapp-template) | [vue-uniapp-template](https://gitcode.com/youlai/vue-uniapp-template) | [vue-uniapp-template](https://gitcode.com/youlaitech/vue-uniapp-template) |
|
| 移动端 | [vue-uniapp-template](https://gitcode.com/youlai/vue-uniapp-template) | [vue-uniapp-template](https://gitee.com/youlaiorg/vue-uniapp-template) | [vue-uniapp-template](https://gitcode.com/youlaitech/vue-uniapp-template) |
|
||||||
|
|
||||||
## 📚 文档地址
|
## 📚 文档地址
|
||||||
|
|
||||||
|
|||||||
@@ -19,10 +19,8 @@ import jakarta.servlet.http.HttpServletResponse;
|
|||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.aspectj.lang.JoinPoint;
|
import org.aspectj.lang.JoinPoint;
|
||||||
import org.aspectj.lang.annotation.AfterReturning;
|
import org.aspectj.lang.ProceedingJoinPoint;
|
||||||
import org.aspectj.lang.annotation.AfterThrowing;
|
import org.aspectj.lang.annotation.*;
|
||||||
import org.aspectj.lang.annotation.Aspect;
|
|
||||||
import org.aspectj.lang.annotation.Pointcut;
|
|
||||||
import org.springframework.cache.CacheManager;
|
import org.springframework.cache.CacheManager;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import org.springframework.web.context.request.RequestContextHolder;
|
import org.springframework.web.context.request.RequestContextHolder;
|
||||||
@@ -61,23 +59,25 @@ public class LogAspect {
|
|||||||
*
|
*
|
||||||
* @param joinPoint 切点
|
* @param joinPoint 切点
|
||||||
*/
|
*/
|
||||||
@AfterReturning(pointcut = "logPointcut() && @annotation(logAnnotation)", returning = "jsonResult")
|
@Around("logPointcut() && @annotation(logAnnotation)")
|
||||||
public void doAfterReturning(JoinPoint joinPoint, com.youlai.boot.common.annotation.Log logAnnotation, Object jsonResult) {
|
public Object doAround(ProceedingJoinPoint joinPoint, com.youlai.boot.common.annotation.Log logAnnotation) throws Throwable {
|
||||||
this.saveLog(joinPoint, null, jsonResult, logAnnotation);
|
TimeInterval timer = DateUtil.timer();
|
||||||
|
Object result = null;
|
||||||
|
Exception exception = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
result = joinPoint.proceed();
|
||||||
|
} catch (Exception e) {
|
||||||
|
exception = e;
|
||||||
|
throw e;
|
||||||
|
} finally {
|
||||||
|
long executionTime = timer.interval(); // 执行时长
|
||||||
|
this.saveLog(joinPoint, exception, result, logAnnotation, executionTime);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 拦截异常操作
|
|
||||||
*
|
|
||||||
* @param joinPoint 切点
|
|
||||||
* @param e 异常
|
|
||||||
*/
|
|
||||||
@AfterThrowing(value = "logPointcut()", throwing = "e")
|
|
||||||
public void doAfterThrowing(JoinPoint joinPoint, Exception e) {
|
|
||||||
this.saveLog(joinPoint, e, null, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 保存日志
|
* 保存日志
|
||||||
*
|
*
|
||||||
@@ -86,15 +86,11 @@ public class LogAspect {
|
|||||||
* @param jsonResult 响应结果
|
* @param jsonResult 响应结果
|
||||||
* @param logAnnotation 日志注解
|
* @param logAnnotation 日志注解
|
||||||
*/
|
*/
|
||||||
private void saveLog(final JoinPoint joinPoint, final Exception e, Object jsonResult, com.youlai.boot.common.annotation.Log logAnnotation) {
|
private void saveLog(final JoinPoint joinPoint, final Exception e, Object jsonResult, com.youlai.boot.common.annotation.Log logAnnotation, long executionTime) {
|
||||||
String requestURI = request.getRequestURI();
|
String requestURI = request.getRequestURI();
|
||||||
|
|
||||||
TimeInterval timer = DateUtil.timer();
|
|
||||||
// 执行方法
|
|
||||||
long executionTime = timer.interval();
|
|
||||||
|
|
||||||
// 创建日志记录
|
// 创建日志记录
|
||||||
Log log = new Log();
|
Log log = new Log();
|
||||||
|
log.setExecutionTime(executionTime);
|
||||||
if (logAnnotation == null && e != null) {
|
if (logAnnotation == null && e != null) {
|
||||||
log.setModule(LogModuleEnum.EXCEPTION);
|
log.setModule(LogModuleEnum.EXCEPTION);
|
||||||
log.setContent("系统发生异常");
|
log.setContent("系统发生异常");
|
||||||
@@ -129,7 +125,7 @@ public class LogAspect {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
log.setExecutionTime(executionTime);
|
|
||||||
// 获取浏览器和终端系统信息
|
// 获取浏览器和终端系统信息
|
||||||
String userAgentString = request.getHeader("User-Agent");
|
String userAgentString = request.getHeader("User-Agent");
|
||||||
UserAgent userAgent = resolveUserAgent(userAgentString);
|
UserAgent userAgent = resolveUserAgent(userAgentString);
|
||||||
|
|||||||
Reference in New Issue
Block a user