using System; using System.Runtime.Serialization; namespace SlnMesnac.Model.dto { /// /// 接口返回信息 /// [DataContract(Name = "ApiResponse 返回信息")] public class ApiResponse { /// /// 状态码,成功-200,异常-500 /// public int StatusCode { get; set; } /// /// 是否成功 /// public bool IsSuccess { get; set; } /// /// 信息 /// public string Message { get; set; } /// /// 成功 /// /// public void SetSuccess(string message = "") { StatusCode = 200; IsSuccess = true; Message = message; } /// /// 失败 /// /// public void SetFailure(string message = "") { StatusCode = 500; IsSuccess = false; Message = message; } /// /// 异常 /// /// /// public void SetException(Exception ex, string message = "") { StatusCode = 500; IsSuccess = false; Message = message + ex.Message; } } }