|
|
|
@ -120,15 +120,15 @@ public class ApiMessageAdvisor { |
|
|
|
|
* @return RequestId |
|
|
|
|
*/ |
|
|
|
|
private String getRequestId(){ |
|
|
|
|
UUID existUUID = RequestIdUtils.getRequestId(); |
|
|
|
|
if(existUUID != null){ |
|
|
|
|
return existUUID.toString(); |
|
|
|
|
} |
|
|
|
|
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); |
|
|
|
|
if(attributes == null || !StringUtils.hasText(attributes.getRequest().getHeader("x-request-id"))) { |
|
|
|
|
RequestIdUtils.generateRequestId(); |
|
|
|
|
return RequestIdUtils.getRequestId().toString(); |
|
|
|
|
} |
|
|
|
|
UUID existUUID = RequestIdUtils.getRequestId(); |
|
|
|
|
if(existUUID != null){ |
|
|
|
|
return existUUID.toString(); |
|
|
|
|
} |
|
|
|
|
// 因为如果有网关,则一般会从网关传递过来,所以优先从header头获取
|
|
|
|
|
HttpServletRequest request = attributes.getRequest(); |
|
|
|
|
String requestId = request.getHeader("x-request-id"); |
|
|
|
|