public class BizException extends RuntimeException {
private int errorCode;
private String errorMsg;
public BizException() {
super();
}
public BizException(String message) {
super(message);
}
public BizException(int errorCode, String errorMsg) {
super(errorMsg);
this.errorCode = errorCode;
this.errorMsg = errorMsg;
}
}
public class Result<T> {
private int code;
private String message;
private T data;
private Result(int code, String message, T data) {
this.code = code;
this.message = message;
this.data = data;
}
public static <T> Result<T> success(T data) {
return new Result<>(200, "Success", data);
}
public static <T> Result<T> error(int code, String message) {
return new Result<>(code, message, null);
}
}