namespace WS
{
    ///<summary>Http Output 接口</summary>
    public interface IResponseOutput
    {
        /// <summary>是否成功标记</summary>
        bool success { get; set; }

        /// <summary>状态码</summary>
        int code { get; set; }

        /// <summary>消息</summary>
        string msg { get; set; }
    }

    ///<summary>Http Output 数据</summary>
    public class ResponseOutput<T> : IResponseOutput
    {
        /// <summary>是否成功标记</summary>
        public bool success { get; set; }

        /// <summary>状态码</summary>
        public int code { get; set; }

        /// <summary>消息</summary>
        public string msg { get; set; }

        public string own { get; set; }
        public string uid { get; set; }
        public string um { get; set; }

        /// <summary>数据</summary>
        public T data { get; set; }
        /// <summary>失败</summary>
        /// <param name="code">状态码</param>
        /// <param name="msg">消息</param>
        /// <param name="data">数据</param>
        public ResponseOutput<T> NotOk(int code, string msg = null, T data = default(T))
        {
            this.success = false;
            this.code = code;
            this.msg = msg;
            this.data = data;
            return this;
        }

        ///<summary>网络请求错误</summary>
        public ResponseOutput<T> NetworkError(string msg, int code)
        {
            return NotOk(code, msg);
        }
    }
}