package com.koobietech.eas.common.result;

import java.io.Serializable;

public class JsonPageResult<T> implements Serializable {
    private boolean status = false;
    private String msg = "";
    private T data = null;
    private Long total = 0L;

    public static JsonPageResult data(PageDataResult data , String message  ){
        JsonPageResult result = JsonPageResult.ok();
        result.setTotal(data.getTotal());
        result.setData(data.getData());
        result.setMsg(message);
        return result;
    }

    public static JsonPageResult data( PageDataResult data  ){
        JsonPageResult result = JsonPageResult.ok();
        result.setData(data.getData());
        result.setTotal(data.getTotal());
        return result;
    }

    public static JsonPageResult ok(){
        JsonPageResult result = new JsonPageResult();
        result.setStatus(true);
        result.setMsg("操作成功");
        return result;
    }

    public static JsonPageResult fail( String message ){
        JsonPageResult result = new JsonPageResult();
        result.setStatus(false);
        result.setMsg("操作失败");
        return result;
    }

    public Long getTotal() {
        return total;
    }

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

    public boolean getStatus() {
        return status;
    }

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

    public String getMsg() {
        return msg;
    }

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

    public T getData() {
        return data;
    }

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