jeecgboot/jeecg-boot

文件类型参数导致自动保存日志序列化出错

Closed this issue · 1 comments

版本号: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

截图&代码:
Dingtalk_20240425101445

例如:

	@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;
    }




你是那个分支?