/// <summary> /// 无参的失败返回类型 /// </summary> /// <param name="resultCode"></param> /// <returns></returns> public IActionResult Failure(ResultCode resultCode) { GetStudentGroupResult result = new GetStudentGroupResult(); result.code = (int)resultCode; result.msg = resultCode.GetDescription(); return(Ok(result)); }
/// <summary> /// 不带参失败返回 /// </summary> /// <param name="resultCode"></param> /// <returns></returns> public IActionResult Failure(ResultCode resultCode) { GetCoueseResult result = new GetCoueseResult { code = (int)resultCode, msg = resultCode.GetDescription() }; return(Ok(result)); }
public static ApiResultBase GetInstance(ResultCode code = ResultCode.Default, dynamic result = null, string message = "", string responseTime = "") { var apiResult = new ApiResultBase(); apiResult.Code = code; apiResult.Message = string.IsNullOrEmpty(message) ? code.GetDescription() : message; apiResult.Result = result ?? ""; apiResult.ResponseTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); return(apiResult); }
/// <summary> /// 有参的失败返回类型 /// </summary> /// <param name="resultCode"></param> /// <param name="response"></param> /// <returns></returns> public IActionResult Failure <T>(ResultCode resultCode, T response) { GetStudentGroupResult <T> result = new GetStudentGroupResult <T>(); result.code = (int)resultCode; result.msg = resultCode.GetDescription(); result.data = response; return(Ok(result)); }
/// <summary> /// 带数据失败返回类型 /// </summary> /// <param name="resultCode"></param> /// <param name="data"></param> /// <returns></returns> public IActionResult Failure <T>(ResultCode resultCode, T data) { GetCoueseResult result = new GetCoueseResult { code = (int)resultCode, msg = resultCode.GetDescription(), data = data }; return(Ok(result)); }
/// <summary> /// 返回响应码状态描述 /// </summary> /// <param name="code">返回响应码状态枚举</param> /// <returns></returns> public static ResponseResult GenFaildResponse(ResultCode code = ResultCode.Faild) { return(new ResponseResult { Code = (int)code, Message = code.GetDescription() }); }
public Result(ResultCode code, string msg, T data) { this.code = code; this.msg = msg ?? code.GetDescription(); this.data = data; }
public static string ConvertString(this ResultCode code, params string[] @params) { string description = string.Format(code.GetDescription(), @params); return(string.Format("{0} {1}", (int)code, description)); }
/// <summary> /// /// </summary> /// <param name="resultCode"></param> /// <param name="popup"></param> public ResultMessage(ResultCode resultCode = ResultCode.Ok, PopupOption popup = PopupOption.Default) { Title = resultCode.GetDescription(); Message = resultCode.GetDescription(); Popup = popup; }