namespace OpenAuth.App.ServiceApp.GoView.Response;

public class ResultTable
{
    /**
     * 状态码
     * */
    private int code;

    /**
     * 提示消息
     * */
    private string msg;

    /**
     * 消息总量
     * */
    private long count;

    /**
     * 数据对象
     * */
    private object data;

    public int Code
    {
        get { return code; }
        set { code = value; }
    }

    public string Msg
    {
        get { return msg; }
        set { msg = value; }
    }

    public long Count
    {
        get { return count; }
        set { count = value; }
    }

    public object Data
    {
        get { return data; }
        set { data = value; }
    }

    /**
     * 构建
     * */
    public static ResultTable PageTable(long count, object data)
    {
        ResultTable resultTable = new ResultTable();
        resultTable.Data = data;
        resultTable.Code = 0;
        resultTable.Count = count;
        if (data != null)
        {
            resultTable.Msg = "获取成功";
        }
        else
        {
            resultTable.Msg = "获取失败";
        }

        return resultTable;
    }

    public static ResultTable DataTable(object data)
    {
        ResultTable resultTable = new ResultTable();
        resultTable.Data = data;
        resultTable.Code = 0;
        if (data != null)
        {
            resultTable.Msg = "获取成功";
        }
        else
        {
            resultTable.Msg = "获取失败";
        }

        return resultTable;
    }
}