// Path: src/main/java/org/catframework/agileworking/BusinessException.java
// public class BusinessException extends RuntimeException {
// 
// 	private static final long serialVersionUID = 3999713779564898790L;
// 
// 	private String code;
// 
// 	public BusinessException(String code) {
// 		this.code = code;
// 	}
// 
// 	public BusinessException(String code, String message) {
// 		super(message);
// 		this.code = code;
// 	}
// 
// 	public BusinessException(String code, String message, Throwable cause) {
// 		super(message, cause);
// 		this.code = code;
// 	}
// 
// 	public String getCode() {
// 		return code;
// 	}
// 
// }
// 
// Path: src/main/java/org/catframework/agileworking/common/ResponseCodes.java
// public final class ResponseCodes {
// 
// 	/** 响应码：成功. */
// 	public static final String RESPONSE_CODE_SUCCESS = "SC0000";
// 
// 	/** 响应码：默认的系统处理异常，用于非预期的运行时异常. */
// 	public static final String RESPONSE_CODE_SYSTEM_ERROR = "ER0001";
// }


import java.util.HashMap;
import java.util.Map;
import org.catframework.agileworking.BusinessException;
import org.catframework.agileworking.common.ResponseCodes;
package org.catframework.agileworking.web.support;



public class DefaultResult<T> implements Result<T> {

	/**
	 * 创建一个成功的结果，不含 payload
	 */
	public static Result<?> newResult() {
		DefaultResult<?> result = new DefaultResult<>();
		result.status = Result.STATUS_SUCCESS;
		result.responseCode = ResponseCodes.RESPONSE_CODE_SUCCESS;
		return result;
	}

	/**
	 * 创建一个成功的结果
	 * 
	 * @param payload 结果中的数据
	 * @return 新创建的交易结果
	 */
	public static <T> Result<T> newResult(T payload) {
		DefaultResult<T> result = new DefaultResult<>();
		result.status = Result.STATUS_SUCCESS;
		result.responseCode = ResponseCodes.RESPONSE_CODE_SUCCESS;
		result.payload = payload;
		return result;
	}

	/**
	 * 创建一个失败的结果
	 * 
	 * @param ex 导致交易失败的具体异常
	 * @return 新创建的交易结果
	 */
	public static <T> Result<T> newFailResult(Throwable ex) {
		DefaultResult<T> result = new DefaultResult<>();
		result.status = Result.STATUS_FAIL;
		result.responseMessage = ex.getMessage();
		result.responseCode = (ex instanceof BusinessException) ? ((BusinessException) ex).getCode()
// Path: src/main/java/org/catframework/agileworking/BusinessException.java
// public class BusinessException extends RuntimeException {
// 
// 	private static final long serialVersionUID = 3999713779564898790L;
// 
// 	private String code;
// 
// 	public BusinessException(String code) {
// 		this.code = code;
// 	}
// 
// 	public BusinessException(String code, String message) {
// 		super(message);
// 		this.code = code;
// 	}
// 
// 	public BusinessException(String code, String message, Throwable cause) {
// 		super(message, cause);
// 		this.code = code;
// 	}
// 
// 	public String getCode() {
// 		return code;
// 	}
// 
// }
// 
// Path: src/main/java/org/catframework/agileworking/common/ResponseCodes.java
// public final class ResponseCodes {
// 
// 	/** 响应码：成功. */
// 	public static final String RESPONSE_CODE_SUCCESS = "SC0000";
// 
// 	/** 响应码：默认的系统处理异常，用于非预期的运行时异常. */
// 	public static final String RESPONSE_CODE_SYSTEM_ERROR = "ER0001";
// }


// Path: src/main/java/org/catframework/agileworking/web/support/DefaultResult.java
import java.util.HashMap;
import java.util.Map;
import org.catframework.agileworking.BusinessException;
import org.catframework.agileworking.common.ResponseCodes;

package org.catframework.agileworking.web.support;



public class DefaultResult<T> implements Result<T> {

	/**
	 * 创建一个成功的结果，不含 payload
	 */
	public static Result<?> newResult() {
		DefaultResult<?> result = new DefaultResult<>();
		result.status = Result.STATUS_SUCCESS;
		result.responseCode = ResponseCodes.RESPONSE_CODE_SUCCESS;
		return result;
	}

	/**
	 * 创建一个成功的结果
	 * 
	 * @param payload 结果中的数据
	 * @return 新创建的交易结果
	 */
	public static <T> Result<T> newResult(T payload) {
		DefaultResult<T> result = new DefaultResult<>();
		result.status = Result.STATUS_SUCCESS;
		result.responseCode = ResponseCodes.RESPONSE_CODE_SUCCESS;
		result.payload = payload;
		return result;
	}

	/**
	 * 创建一个失败的结果
	 * 
	 * @param ex 导致交易失败的具体异常
	 * @return 新创建的交易结果
	 */
	public static <T> Result<T> newFailResult(Throwable ex) {
		DefaultResult<T> result = new DefaultResult<>();
		result.status = Result.STATUS_FAIL;
		result.responseMessage = ex.getMessage();
		result.responseCode = (ex instanceof BusinessException) ? ((BusinessException) ex).getCode()
				: ResponseCodes.RESPONSE_CODE_SYSTEM_ERROR;