package cn.yunzhixue.ability.center.kernel;

public record BaseResponse<T>(String code, String message, T data) {

    public static <T> BaseResponse<T> success(T data) {
        return new BaseResponse<>("SUCCESS", "success", data);
    }

    public static BaseResponse<Void> failure(ErrorCode errorCode) {
        return new BaseResponse<>(errorCode.getCode(), errorCode.getMessage(), null);
    }

    public static BaseResponse<Void> failure(ErrorCode errorCode, String message) {
        return new BaseResponse<>(errorCode.getCode(), message, null);
    }
}
