Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

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

Closed
q060831 opened this issue Apr 25, 2024 · 1 comment
Closed

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

q060831 opened this issue Apr 25, 2024 · 1 comment

Comments

@q060831
Copy link

q060831 commented Apr 25, 2024

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




@zhangdaiscott
Copy link
Member

你是那个分支?

EightMonth added a commit to EightMonth/jeecg-boot that referenced this issue Apr 30, 2024
EightMonth added a commit to EightMonth/jeecg-boot that referenced this issue Apr 30, 2024
zhangdaiscott added a commit that referenced this issue Apr 30, 2024
EightMonth added a commit to EightMonth/jeecg-boot that referenced this issue May 13, 2024
zhangdaiscott added a commit that referenced this issue Jun 5, 2024
修复#6100#6169、@IgnoreAuth扫描加速
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants