From 81da61b828e29b7745e1382dfbbaeb685dc083ef Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期二, 23 一月 2024 17:17:55 +0800 Subject: [PATCH] 抖音转链修改 --- fanli/src/main/java/com/yeshi/fanli/aspect/ErrorAspect.java | 131 +++++++++++++++++++++---------------------- 1 files changed, 65 insertions(+), 66 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/aspect/ErrorAspect.java b/fanli/src/main/java/com/yeshi/fanli/aspect/ErrorAspect.java index 24ad486..ec65155 100644 --- a/fanli/src/main/java/com/yeshi/fanli/aspect/ErrorAspect.java +++ b/fanli/src/main/java/com/yeshi/fanli/aspect/ErrorAspect.java @@ -1,66 +1,65 @@ -package com.yeshi.fanli.aspect; - -import java.util.Iterator; -import java.util.Map; - -import javax.servlet.http.HttpServletRequest; - -import org.aspectj.lang.ProceedingJoinPoint; -import org.aspectj.lang.annotation.Around; -import org.aspectj.lang.annotation.Aspect; -import org.springframework.stereotype.Component; -import org.springframework.web.context.request.RequestContextHolder; -import org.springframework.web.context.request.ServletRequestAttributes; - -import com.yeshi.fanli.log.LogHelper; - -import net.sf.json.JSONObject; - -@Component -@Aspect -public class ErrorAspect { - public static final String EDP = "execution(* com.yeshi.fanli.controller.ClientJspController.*(..))"; - - @Around(EDP) - public Object testAround(ProceedingJoinPoint joinPoint) { - ServletRequestAttributes servletContainer = (ServletRequestAttributes) RequestContextHolder - .getRequestAttributes(); - HttpServletRequest request = servletContainer.getRequest(); - Object[] args = joinPoint.getArgs(); - Object obj = null; - try { - obj = joinPoint.proceed(args); - } catch (Throwable e) { - try { - LogHelper.errorDetailInfo(e, getHttpServletParams(request), request.getRequestURI().toString()); - } catch (Exception e1) { - e1.printStackTrace(); - } - } - - return obj; - } - - private String getHttpServletParams(HttpServletRequest request) { - if (request == null) { - return ""; - } - Map map = request.getParameterMap(); - if (map != null) { - Iterator<String> its = map.keySet().iterator(); - JSONObject json = new JSONObject(); - while (its.hasNext()) { - String next = its.next(); - if (map.get(next) != null) { - Object[] objects = (Object[]) map.get(next); - if (objects != null && objects.length > 0) { - json.put(next, objects[0].toString()); - } - } - } - return json.toString(); - } - return ""; - } - -} +package com.yeshi.fanli.aspect; + +import java.util.Iterator; +import java.util.Map; + +import javax.servlet.http.HttpServletRequest; + +import org.aspectj.lang.ProceedingJoinPoint; +import org.aspectj.lang.annotation.Around; +import org.aspectj.lang.annotation.Aspect; +import org.springframework.stereotype.Component; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; + +import com.yeshi.fanli.log.LogHelper; + +import net.sf.json.JSONObject; + +@Component +@Aspect +public class ErrorAspect { + public static final String EDP = "execution(* com.yeshi.fanli.controller.ClientJspController.*(..))"; + + @Around(EDP) + public Object testAround(ProceedingJoinPoint joinPoint) { + ServletRequestAttributes servletContainer = (ServletRequestAttributes) RequestContextHolder + .getRequestAttributes(); + HttpServletRequest request = servletContainer.getRequest(); + Object[] args = joinPoint.getArgs(); + Object obj = null; + try { + obj = joinPoint.proceed(args); + } catch (Throwable e) { + + LogHelper.errorDetailInfo(e, getHttpServletParams(request), request.getRequestURI().toString()); + + } + + return obj; + } + + + private String getHttpServletParams(HttpServletRequest request) { + if (request == null) { + return ""; + } + Map map = request.getParameterMap(); + if (map != null) { + Iterator<String> its = map.keySet().iterator(); + JSONObject json = new JSONObject(); + while (its.hasNext()) { + String next = its.next(); + if (map.get(next) != null) { + Object[] objects = (Object[]) map.get(next); + if (objects != null && objects.length > 0) { + json.put(next, objects[0].toString()); + } + } + } + return json.toString(); + } + return ""; + } + +} -- Gitblit v1.8.0