禅道bug#1588修复

This commit is contained in:
gaoqr
2026-06-05 16:06:56 +08:00
parent 05c6eea837
commit e1369e7302
21 changed files with 158 additions and 15 deletions
@@ -23,6 +23,7 @@ public class GlobalErrorCodeConstants {
public static final ErrorCode NO_PERMISSION_TO_VISIT_ORG = new ErrorCode(400, "global.error.no.permission.to.visit.org");
public static final ErrorCode REQUEST_PARAM_TYPE_ERROR = new ErrorCode(400, "global.error.request.param.type.error");
public static final ErrorCode UNAUTHORIZED = new ErrorCode(401, "global.not.login");
public static final ErrorCode BE_KICKED_OUT = new ErrorCode(401, "be.kicked.out");
public static final ErrorCode FORBIDDEN = new ErrorCode(403, "global.error.no.permission");
public static final ErrorCode REQUEST_PARAM_MISSING = new ErrorCode(403, "global.error.request.param.missing");
public static final ErrorCode NOT_FOUND = new ErrorCode(404, "global.error.request.not.found");
@@ -80,6 +80,20 @@ public class CommonResult<T> implements Serializable {
return result;
}
public static <T> CommonResult<T> error(Integer code, T data, String message) {
Assert.isTrue(!GlobalErrorCodeConstants.SUCCESS.getCode().equals(code), "code 必须是错误的!");
CommonResult<T> result = new CommonResult<>();
result.code = code;
result.msg = message;
result.data = data;
String traceId = MDC.get(TRACE_ID);
if (StringUtils.hasText(traceId)) {
result.traceId = traceId;
}
return result;
}
public static <T> CommonResult<T> error(Integer code, String message, Object... args) {
Assert.isTrue(!GlobalErrorCodeConstants.SUCCESS.getCode().equals(code), "code 必须是错误的!");
CommonResult<T> result = new CommonResult<>();