package com.iamberry.wechat.tools;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

/**
 * 用于对接app接口的json
 * wangxiaoming
 */
public class RespJsonBean implements Serializable {

	private static final long serialVersionUID = -3391219323921796355L;

	private int resultCode = 200;			// 请求code

	private String resultMsg = "SUCCESS";	// 请求code描述

	private Integer returnCode;				// 业务结果

	private Object returnMsg;					//返回结果

	private Map<String, Object> message;	// 返回的结果信息

	/**
	 * 成功时返回
	 */
	public static RespJsonBean SUCCESS = new RespJsonBean(200, "SUCCESS", 200);

	/**
	 * 失败时返回
	 */
	public static RespJsonBean FAILURE = new RespJsonBean(200, "FAILURE", 500);

	public RespJsonBean() {
		super();
	}

	public int getResultCode() {
		return resultCode;
	}

	public void setResultCode(int resultCode) {
		this.resultCode = resultCode;
	}

	public String getResultMsg() {
		return resultMsg;
	}

	public void setResultMsg(String resultMsg) {
		this.resultMsg = resultMsg;
	}

	public Integer getReturnCode() {
		return returnCode;
	}

	public void setReturnCode(Integer returnCode) {
		this.returnCode = returnCode;
	}

	public Map<String, Object> getMessage() {
		return message;
	}

	public void setMessage(Map<String, Object> returnMsg) {
		this.message = returnMsg;
	}


    public Object getReturnMsg() {
        return returnMsg;
    }

    public void setReturnMsg(Object returnMsg) {
        this.returnMsg = returnMsg;
    }

    /**
	 * 添加返回结果 returnMsg='value'结果
	 * @param key
	 * @param value
	 */
	public RespJsonBean addResponseKeyValue(String value) {
		if (this.message == null) {
			message = new HashMap<String, Object>();
		}
		this.message.put("returnMsg", value);
		return this;
	}

	/**
	 * 添加返回结果 key='value'结果
	 * @param key
	 * @param value
	 */
	public RespJsonBean addResponseKeyValue(String Key, Object value) {
		if (this.message == null) {
			message = new HashMap<String, Object>();
		}
		this.message.put(Key, value);
		return this;
	}

	public RespJsonBean(int resultCode, String resultMsg, Integer returnCode) {
		super();
		this.resultCode = resultCode;
		this.resultMsg = resultMsg;
		this.returnCode = returnCode;
	}

	public RespJsonBean(Integer returnCode, String returnMsg){
		super();
		this.returnCode = returnCode;
		addResponseKeyValue(returnMsg);
	}
}
