文件类型参数导致自动保存日志序列化出错
Closed this issue · 1 comments
q060831 commented
版本号:3.6.3
前端版本:vue3版
问题描述:文件类型参数导致自动保存日志序列化报错write javaBean error, fastjson version 1.2.83, class org.springframework.web.multipart.support.StandardMultipartHttpServletRequest$StandardMultipartFile, fieldName : file_tag_10, write javaBean error, fastjson version 1.2.83, class org.springframework.web.multipart.MultipartFileResource, fieldName : resource
例如:
@AutoLog(value = "编辑")
@ApiOperation(value="编辑", notes="编辑")
@RequestMapping(value = "/edit", method = RequestMethod.POST)
public Result<?> edit(SaveDTO dto) {
System.out.println("dto:");
System.out.println(dto);
System.out.println("dto.id:");
System.out.println(dto.getId());
return Result.ERROR("操作失败");
}
public class SaveDTO {
private String id;
private Map<String, MultipartFile> files;
}
我的解决方法:
在AutoLogAspect
类的getReqestParams
方法中排序不能序列化的属性
private String getReqestParams(HttpServletRequest request, JoinPoint joinPoint) {
String httpMethod = request.getMethod();
String params = "";
if (CommonConstant.HTTP_POST.equals(httpMethod) || CommonConstant.HTTP_PUT.equals(httpMethod) || CommonConstant.HTTP_PATCH.equals(httpMethod)) {
...
//update-begin-author:taoyan date:20200724 for:日志数据太长的直接过滤掉
PropertyFilter profilter = new PropertyFilter() {
@Override
public boolean apply(Object o, String name, Object value) {
int length = 500;
if(value!=null && value.toString().length()>length){
return false;
}
// 添加了这个
if(value instanceof MultipartFile){
return false;
}
return true;
}
};
params = JSONObject.toJSONString(arguments, profilter);
//update-end-author:taoyan date:20200724 for:日志数据太长的直接过滤掉
} else {
....
}
return params;
}
zhangdaiscott commented
你是那个分支?