package com.community.huiju.common.base;

import java.io.Serializable;

/**
 * 接口统一状态返回BEAN.
 */
public class ResponseBean<T> implements Serializable {

    private static final long serialVersionUID = 3593827217136880822L;

    private Integer code = 0;

    private String message = "成功";

    private T data;

    public ResponseBean() {
    }

    public void addError(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    public void addSuccess(String message) {
        this.code = 0;
        this.message = message;
    }

    public void addSuccess(Integer code, T data) {
        this.code = code;
        this.message = "成功";
        this.data = data;
    }

    public void addSuccess(Integer code, String message, T data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }

    public void addSuccess(String message, T data) {
        this.code = 0;
        this.message = message;
        this.data = data;
    }

    public void addSuccess(T data) {
        this.code = 0;
        this.message = "成功";
        this.data = data;
    }

    public T getData() {
        return this.data;
    }

    public Integer getCode() {
        return this.code;
    }

    public String getMessage() {
        return this.message;
    }

    @Override
    public String toString() {
        return "ResponseBaseBean [code=" + this.code + ", message=" + this.message + ", data=" + this.data + "]";
    }

}
