package com.yeejoin.amos.jpush.common.entity;

import java.io.Serializable;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature;

import io.swagger.annotations.ApiModelProperty;

/**
 * <pre>
 * 返回封装对象
 * </pre>
 *
 * @author mincx
 * @version CommonReponse.java v0.1
 * @time 2017-9-19 15:43:32
 */
public class CommonResponse implements Serializable {
	private static final long serialVersionUID = -8737351878134480646L;

	/**
	 * 操作状态
	 */
	@ApiModelProperty(required=true,value="操作状态")
	private String result;

	/**
	 * 数据
	 */
	@ApiModelProperty(required=false,value="数据")
	private Object dataList;

	/**
	 * 操作详细信息
	 */
	@ApiModelProperty(required=false,value="操作详细信息")
	private String message;
	
    public CommonResponse(){

    }
    
    public CommonResponse(String result) {
		this.result = result;
	}

	public CommonResponse(Object dataList) {
		this.dataList = dataList;
		this.result = "";
	}

	public CommonResponse(String result, Object dataList) {
		this.dataList = dataList;
		this.result = result;
	}

	public CommonResponse(String result, String message) {
		this.result = result;
		this.message = message;
	}

	public CommonResponse(String result, Object dataList, String message) {
		this.dataList = dataList;
		this.result = result;
		this.message = message;
	}

    public Boolean isSuccess(){
        return "SUCCESS".equals(getResult());
    }

    public String getResult() {
        return result;
    }

    public void setResult(String result) {
        this.result = result;
    }

    public String getMessage() {
        return message;
    }

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

    public Object getDataList() {
        return dataList;
    }

    public void setDataList(Object dataList) {
        this.dataList = dataList;
    }
    
    public String toJsonStr() throws Exception {
		return JSON.toJSONString(this,SerializerFeature.WriteMapNullValue,SerializerFeature.DisableCircularReferenceDetect,SerializerFeature.SkipTransientField);
	}
}
