/*
   *  Date	 :2015-6-4 14:02
   *  Author:吴梦飞
   *  Desc  :
   */
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Nirvana.Common.ApiBase
{
    public class ReturnStatus
    {
        public int code { get; set; }
        public string name { get; set; }
        public string message { get; set; }
        public string devSerial { get; set; }

        public static ReturnStatus GetByResult(APIResult apiresult, string msg="")
        {
            return new ReturnStatus()
            {
                code = (int)apiresult,
                name=apiresult.ToString(),
                message = msg
            };
        }
        public static ReturnStatus GetByResult(JFAPIRESULT apiresult, string msg = "")
        {
            return new ReturnStatus()
            {
                code = (int)apiresult,
                message = msg
            };
        }
        /// <summary>
        /// 针对OEM返回特殊处理
        /// </summary>
        /// <param name="apiresult"></param>
        /// <param name="msg"></param>
        /// <returns></returns>
        public static ReturnStatus OEMGetByResult(APIResult apiresult, string msg = "", string devSerial = "")
        {
            return new ReturnStatus()
            {
                code = (int)apiresult,
                name = apiresult.ToString(),
                message = msg,
                devSerial = devSerial
            };
        }

        private class JsonStatus
        {
            public ReturnStatus status { get; set; }
        }

        public string ToJson()
        {
            var status = new JsonStatus() { status = this };
            return Newtonsoft.Json.JsonConvert.SerializeObject(status);
        }
    }

    public class WzStatus
    {
        public ReturnStatus status { get; set; }
    }

    public class ReturnStatusV2
    {
        public int code { get; set; }
        public string name { get; set; }
        public string message { get; set; }

        public static ReturnStatusV2 GetByResult(APIResult apiresult, string msg)
        {
            return new ReturnStatusV2()
            {
                code = (int)apiresult,
                name = apiresult.ToString(),
                message = msg
            };
        }
        private class JsonStatusV2
        {
            public ReturnStatusV2 status { get; set; }
        }

        public string ToJson()
        {
            return Newtonsoft.Json.JsonConvert.SerializeObject(this);
        }
    }
}
