using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace DPumpHydr.OpenModel { /// /// 执行返回的通用类,该类不带业务数据,只会告诉用户此次调用是否成功与否,以及一个表示提示信息的字符串 /// public class ApiResult { /// /// 状态信息 /// public ApiResultCode Code { get; set; } /// /// 提示信息 /// public string Message { get; set; } /// /// 构造函数 /// public ApiResult() { this.Code = ApiResultCode.Success; } /// /// 构造函数 /// /// 结果状态标识 /// 提示信息 public ApiResult(ApiResultCode type, string message) { this.Code = type; this.Message = message; } /// /// 构造函数,默认返回状态Error /// /// 提示信息 public ApiResult(string message) { this.Code = ApiResultCode.Error; this.Message = message; } /// /// 构造函数 /// /// 状态标识 public ApiResult(ApiResultCode type) : this(type, "") { } /// /// 返回一个表示通用的出错对象 /// /// 提示信息 /// 通用的出错对象 public static ApiResult Error(string message) { return new ApiResult(ApiResultCode.Error, message); } /// /// 返回一个表示通用的成功对象 /// /// 提示信息 /// 通用的成功对象 public static ApiResult Success(string message = "") { return new ApiResult(ApiResultCode.Success, message); } } }