|
|
@@ -4,7 +4,7 @@ import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.serializer.SerializerFeature;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import me.zhengjie.utils.IpAddressUtil;
|
|
|
-
|
|
|
+import org.springframework.web.multipart.support.StandardMultipartHttpServletRequest;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.aspectj.lang.JoinPoint;
|
|
|
import org.aspectj.lang.Signature;
|
|
|
@@ -62,15 +62,45 @@ public class LogRequestParam {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- Map<String, Object> params = new HashMap<>(4);
|
|
|
+ Map<Object, Object> params = new HashMap<>(4);
|
|
|
for (int i = 0; i < parameterNames.length; i++) {
|
|
|
- Object o = parameterNames[i];
|
|
|
- if (o instanceof MultipartFile || o instanceof MultipartFile[] || o instanceof HttpServletRequest
|
|
|
- || o instanceof HttpServletResponse || o instanceof MultipartFile[]
|
|
|
- || o instanceof MultipartFile || o instanceof MultipartFile[]) {
|
|
|
+ Object param = parameterNames[i];
|
|
|
+
|
|
|
+ if (param == null || param instanceof HttpServletRequest || param instanceof HttpServletResponse) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (param instanceof MultipartFile) {
|
|
|
+ MultipartFile part = (MultipartFile) param;
|
|
|
+ param = part.getOriginalFilename();
|
|
|
+ }
|
|
|
+ if (param instanceof MultipartFile[]) {
|
|
|
+ MultipartFile[] part = (MultipartFile[]) param;
|
|
|
+ StringBuffer sb = new StringBuffer();
|
|
|
+ for (MultipartFile file : part) {
|
|
|
+ sb.append(file.getOriginalFilename() + ",");
|
|
|
+ }
|
|
|
+ param = sb.toString();
|
|
|
+ }
|
|
|
+ // o instanceof MultipartFile || o instanceof MultipartFile[]
|
|
|
+
|
|
|
+ Object value = parameterValues[i];
|
|
|
+ if (value == null || value instanceof HttpServletRequest || value instanceof HttpServletResponse) {
|
|
|
continue;
|
|
|
}
|
|
|
- params.put(parameterNames[i], parameterValues[i]);
|
|
|
+ if (value instanceof MultipartFile) {
|
|
|
+ MultipartFile part = (MultipartFile)value;
|
|
|
+ value = part.getOriginalFilename();
|
|
|
+ }
|
|
|
+ if (value instanceof MultipartFile[]) {
|
|
|
+ MultipartFile[] part = (MultipartFile[]) value;
|
|
|
+ StringBuffer sb = new StringBuffer();
|
|
|
+ for (MultipartFile file : part) {
|
|
|
+ sb.append(file.getOriginalFilename() + ",");
|
|
|
+ }
|
|
|
+ value = sb.toString();
|
|
|
+ }
|
|
|
+ //记录上传的参数
|
|
|
+ params.put(param, value);
|
|
|
}
|
|
|
Object[] obj = { ip, uri, JSON.toJSONString(params, SerializerFeature.WriteMapNullValue) };
|
|
|
log.info("[request] - ip: {} , requestUrl: {} ,param: {} ", obj);
|