mirror of
http://192.168.1.205:9980/cf_devdept2/cf_imes_server.git
synced 2026-08-12 21:02:08 +08:00
1、新增tracefilter中的trace-id,服务日志mdc打印和请求响应增加trace-id;2、恢复access_api_log和access_error_log的清理定时任务;3、补充服务中的线程池使用TransmittableThreadLocal;
This commit is contained in:
+14
@@ -0,0 +1,14 @@
|
||||
package com.cf.imes.framework.common.enums;
|
||||
|
||||
/**
|
||||
* 系统跟踪常量
|
||||
*
|
||||
* @author Gqr
|
||||
* @since 2025/7/7 10:30
|
||||
*/
|
||||
public class TraceConstants {
|
||||
/**
|
||||
* 链路追踪编号
|
||||
*/
|
||||
public static final String TRACE_ID = "trace-id";
|
||||
}
|
||||
+16
@@ -4,14 +4,19 @@ import com.cf.imes.framework.common.exception.ErrorCode;
|
||||
import com.cf.imes.framework.common.exception.ServiceException;
|
||||
import com.cf.imes.framework.common.exception.enums.GlobalErrorCodeConstants;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import lombok.Data;
|
||||
import org.slf4j.MDC;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.util.Objects;
|
||||
|
||||
import static com.cf.imes.framework.common.enums.TraceConstants.TRACE_ID;
|
||||
|
||||
/**
|
||||
* 通用返回
|
||||
*
|
||||
@@ -37,6 +42,12 @@ public class CommonResult<T> implements Serializable {
|
||||
*/
|
||||
private String msg;
|
||||
|
||||
/**
|
||||
* 链路追踪编号
|
||||
*/
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
private String traceId;
|
||||
|
||||
/**
|
||||
* 将传入的 result 对象,转换成另外一个泛型结果的对象
|
||||
*
|
||||
@@ -55,6 +66,11 @@ public class CommonResult<T> implements Serializable {
|
||||
CommonResult<T> result = new CommonResult<>();
|
||||
result.code = code;
|
||||
result.msg = message;
|
||||
|
||||
String traceId = MDC.get(TRACE_ID);
|
||||
if (StringUtils.hasText(traceId)) {
|
||||
result.traceId = traceId;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user