package com.zhangmeng.model.vo;

import java.io.Serializable;

/**
 * @author zhangmeng
 * @version 1.0
 * @date 2020年11月13日09:59:13
 *
 */
public class Result<T> implements Serializable {

    private static final long serialVersionUID = -212536912267261005L;

    /**
     * 是否成功
     */
    private boolean flag;

    /**
     * 返回码
     */
    private Integer code;

    /**
     * 返回消息
     */
    private String message;

    private long count;

    /**
     * 返回数据
     */
    private T data;

    public static Result error(String message) {
        return new Result(false,StatusCode.ERROR,message);
    }

    public static Result error(Integer code,String message) {
        return new Result(false,code,message);
    }

    public long getCount() {
        return count;
    }

    public void setCount(long count) {
        this.count = count;
    }



    public Result() {
    }

    public Result(boolean flag, Integer code) {
        this.flag = flag;
        this.code = code;
    }

    public Result(boolean flag, Integer code, String message) {
        this.flag = flag;
        this.code = code;
        this.message = message;
    }

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

    public Result(boolean flag, Integer code, String message, Object data) {
        this.flag = flag;
        this.code = code;
        this.message = message;
        this.data = (T) data;
    }

    public Result(boolean flag, Integer code, String message, long count, Object data){
        this.flag = flag;
        this.code = code;
        this.message = message;
        this.data =  (T)data;
        this.count = count;
    }

    public boolean isFlag() {
        return flag;
    }

    public void setFlag(boolean flag) {
        this.flag = flag;
    }

    public Integer getCode() {
        return code;
    }

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

    public String getMessage() {
        return message;
    }

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

    public T getData() {
        return data;
    }

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