本人微信 zf363133213 欢迎各位添加好友,共同探讨问题
我在项目中的用到@ControllerAdvice,ResponseBodyAdvice
beforeBodyWrite方法中内容大概如下:
可以在返回的body中加入其他信息
ResponseResult result =(ResponseResult)body;
result.setRequestId(AppContextt.getResquestThreadId());
向日志表中加入信息
UserLogDTO dto =new UserLogDTO();
dto.setUrl(request.getURI().getPath());
dto.setParams(IOUtIls.toString(request.getBody()));
dto.setResult(JSON.toJSONString(body));
commService.insertLog(dto);
return body;