using System; using System.Collections.Generic; using System.Net; using System.Text; namespace XYY.Core.Standard.Mvc { /// /// 泛型对象 /// /// public class ApiJsonModel { /// /// 错误码(0表示无错误) /// public HttpStatusCode code { get; set; } /// /// 是否成功 /// public bool success { get; set; } /// /// 错误信息 /// public string error { get; set; } /// /// 消息 /// public string message { get; set; } /// /// Json数据 /// public T data { get; set; } public string Guid { get; set; } public static ApiJsonModel OK(T data) { return new ApiJsonModel { code = HttpStatusCode.OK, data = data, success = true, message = "成功" }; } public static ApiJsonModel Error(string message, T data) { return new ApiJsonModel { code = HttpStatusCode.InternalServerError, data = data, success = false, message = message }; } } [Serializable] public class ApiJsonModel : ApiJsonModel { /// /// 错误码(0表示无错误) /// public HttpStatusCode code { get; set; } /// /// 是否成功 /// public bool success { get; set; } /// /// 错误信息 /// public string error { get; set; } /// /// 消息 /// public string message { get; set; } /// /// Json数据 /// public object data { get; set; } public static ApiJsonModel OK(object data = null) { return new ApiJsonModel { code = HttpStatusCode.OK, data = data, success = true, message = "成功" }; } public static ApiJsonModel Error(string message, object data = null) { return new ApiJsonModel { code = HttpStatusCode.InternalServerError, data = data, success = false, message = message }; } } }