全局异常捕获;参数校验
Sync All Branches to GitHub / sync (push) Successful in 2s

This commit is contained in:
2026-01-15 15:23:47 +08:00
parent f9613d2e01
commit 0f069433bc
18 changed files with 158 additions and 368 deletions
@@ -14,13 +14,13 @@ public interface BaseExceptionInterface {
*
* @return 异常码
*/
String getCode();
String getErrorCode();
/**
* 获取异常信息
*
* @return 异常信息
*/
String getMessage();
String getErrorMessage();
}
@@ -18,12 +18,12 @@ public class BizException extends RuntimeException {
/**
* 异常码
*/
private String code;
private String errorCode;
/**
* 异常信息
*/
private String message;
private String errorMessage;
/**
* 构造函数
@@ -31,8 +31,8 @@ public class BizException extends RuntimeException {
* @param baseExceptionInterface 基础异常接口
*/
public BizException(BaseExceptionInterface baseExceptionInterface) {
this.code = baseExceptionInterface.getCode();
this.message = baseExceptionInterface.getMessage();
this.errorCode = baseExceptionInterface.getErrorCode();
this.errorMessage = baseExceptionInterface.getErrorMessage();
}
}
@@ -2,6 +2,7 @@ package com.jy.framework.common.response;
import java.io.Serial;
import java.io.Serializable;
import java.time.LocalDateTime;
import lombok.Data;
import com.jy.framework.common.exception.BaseExceptionInterface;
@@ -31,6 +32,11 @@ public class Response<T> implements Serializable {
*/
private String message;
/**
* 响应时间
*/
private LocalDateTime time = LocalDateTime.now();
/**
* 是否成功
*/
@@ -110,8 +116,8 @@ public class Response<T> implements Serializable {
public static <T> Response<T> failure(BizException bizException) {
Response<T> response = new Response<>();
response.setSuccess(false);
response.setCode(bizException.getCode());
response.setMessage(bizException.getMessage());
response.setCode(bizException.getErrorCode());
response.setMessage(bizException.getErrorMessage());
return response;
}
@@ -125,8 +131,8 @@ public class Response<T> implements Serializable {
public static <T> Response<T> failure(BaseExceptionInterface baseExceptionInterface) {
Response<T> response = new Response<>();
response.setSuccess(false);
response.setCode(baseExceptionInterface.getCode());
response.setMessage(baseExceptionInterface.getMessage());
response.setCode(baseExceptionInterface.getErrorCode());
response.setMessage(baseExceptionInterface.getErrorMessage());
return response;
}
}