package com.iamberry.wechat.core.entity;

import com.iamberry.wechat.tools.ResponseJson;

import java.util.HashMap;
import java.util.Map;

/**
 * @description 作为服务影响的返回结果，常用业务错误，返回错误码和错误信息；
 * @author 欧阳明
 * @data 2016-4-18 14:23
 */
public class ResultMsg implements java.io.Serializable{

	/**
	 * 
	 */
	private static final long serialVersionUID = 8987614804726091566L;

	private boolean status; // 状态
	
	private String ResultCode ; //状态码
	
	private String message; //返回信息
	
	private Object data; //返回对象

	public static ResultMsg getSuccess(){
		return new ResultMsg(true, "200", "success",null);
	}
	public static ResultMsg getError(){return new ResultMsg(false, "500", "error",null);	}

	public ResultMsg(){}
	
	public ResultMsg(boolean status, String resultCode, String message,
			Object data) {
		super();
		this.status = status;
		ResultCode = resultCode;
		this.message = message;
		this.data = data;
	}

	public boolean isStatus() {
		return status;
	}

	public void setStatus(boolean status) {
		this.status = status;
	}

	public String getResultCode() {
		return ResultCode;
	}

	public void setResultCode(String resultCode) {
		ResultCode = resultCode;
	}

	public String getMessage() {
		return message;
	}

	public void setMessage(String message) {
		this.message = message;
	}

	public Object getData() {
		return data;
	}

	public void setData(Object data) {
		this.data = data;
	}

	/**
	 * 添加
	 */
	public ResultMsg addData(String Key, Object value) {
		if (this.data == null) {
			Map map = new HashMap();
			map.put(Key, value);
			this.setData(map);
		}else{
			Map map = (Map) this.getData();
			map.put(Key, value);
			this.setData(map);
		}
		return this;
	}


}
