package com.gyee.wisdom.common.data;

import java.io.Serializable;

public class BaseResult<T> implements Serializable {

    private static final long serialVersionUID = -4185151304730685014L;

    protected boolean success;
    protected String error;
    /**
     * 处理结果状态码
     * 200表示成功
     */
    protected int code;
    protected int total;
    private T data;

    public BaseResult() {
    }

    public BaseResult(boolean success, String error, int code) {
        this.success = success;
        this.error = error;
        this.code = success?200:code;
    }

    public BaseResult(boolean success, String error) {
        this.success = success;
        this.error = error;
    }

    public BaseResult(boolean success, T data) {
        this.success = success;
        this.data = data;
        this.code = 200;
    }

    public boolean isSuccess() {
        return success;
    }

    public void setSuccess(boolean success) {
        this.success = success;
    }

    public T getData() {
        return data;
    }

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

    public String getError() {
        return error;
    }

    public void setError(String error) {
        this.error = error;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }



    public int getTotal() {
        return total;
    }

    public void setTotal(int total) {
        this.total = total;
    }

    @Override
    public String toString() {
        return "BaseResult [success=" + success + ", data=" + data + ", error="
                + error + "]";
    }

}