Ver código fonte

修改上传问题

humuyu 3 anos atrás
pai
commit
a7df818460

+ 8 - 2
eladmin-logging/src/main/java/me/zhengjie/aspect/LogRequestParam.java

@@ -13,6 +13,7 @@ import org.aspectj.lang.annotation.Aspect;
 import org.aspectj.lang.annotation.Before;
 import org.aspectj.lang.annotation.Pointcut;
 import org.aspectj.lang.reflect.CodeSignature;
+import org.springframework.core.io.AbstractResource;
 import org.springframework.stereotype.Component;
 import org.springframework.web.context.request.RequestContextHolder;
 import org.springframework.web.context.request.ServletRequestAttributes;
@@ -82,6 +83,11 @@ public class LogRequestParam {
 					}
 					value = sb.toString();
 				}
+				if (value instanceof AbstractResource) {
+					AbstractResource part = (AbstractResource) value;
+					value = part.getFilename();
+				}
+
 				if (value instanceof String) {
 					String str = (String) value;
 					if (str.length() > 1000) {
@@ -96,7 +102,7 @@ public class LogRequestParam {
 			// 请求方法
 			String method = request.getMethod();
 			// 这里判断
-			Object[] obj = { ip,method, uri, json };
+			Object[] obj = { ip, method, uri, json };
 			log.info("[request] - ip: {} , method: {} , requestUrl: {} , param: {} ", obj);
 		} catch (Exception e) {
 			e.printStackTrace();
@@ -123,7 +129,7 @@ public class LogRequestParam {
 			if (StringUtils.isNotBlank(json) && json.length() < 1500) {
 				String uri = request.getRequestURI();
 				String method = request.getMethod();
-				Object obj[] = { status,method, uri, json };
+				Object obj[] = { status, method, uri, json };
 				log.info("[reponse] - status: {} ,method:{}, url:{} ,result:{}", obj);
 			}