package cn.palmte.work.bean;


import cn.palmte.work.config.Constant;


public class ResponseMsg {
    private int status;
    private String msg;
    private Object data;

    public ResponseMsg() {
    }

    public ResponseMsg(int status, String msg) {
        this.status = status;
        this.msg = msg;
    }

    public static ResponseMsg buildSuccessMsg(String msg) {
        return new ResponseMsg(Constant.Status.STATUS_SUCCESS, msg);
    }

    public static ResponseMsg buildSuccessData(Object data) {
        return buildSuccessMsg("ok", data);
    }

    public static ResponseMsg buildSuccessMsg(String msg, Object data) {
        ResponseMsg responseMsg = new ResponseMsg(Constant.Status.STATUS_SUCCESS, msg);
        responseMsg.setData(data);
        return responseMsg;
    }

    public static ResponseMsg buildMsg(int status, String msg, Object data) {
        ResponseMsg responseMsg = new ResponseMsg(status, msg);
        responseMsg.setData(data);
        return responseMsg;
    }

    public static ResponseMsg buildFailedMsg(String msg) {
        return new ResponseMsg(Constant.Status.STATUS_FAILED, msg);
    }

    public static ResponseMsg buildFailedMsg(String msg, Object data) {
        ResponseMsg responseMsg = new ResponseMsg(Constant.Status.STATUS_FAILED, msg);
        responseMsg.setData(data);
        return responseMsg;
    }

    public int getStatus() {
        return status;
    }

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

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Object getData() {
        return data;
    }

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


    public boolean isSuccess() {
        return Constant.Status.STATUS_SUCCESS == this.status;
    }

    @Override
    public String toString() {
        return "ResponseMsg{" +
                "status=" + status +
                ", msg='" + msg + '\'' +
                ", data=" + data +
                '}';
    }

}