public static KingResponse GetResponse(KingRequest request, object data) { KingResponse response = new KingResponse(); response.Success = true; response.ErrorMsg = ""; if (request != null) { response.RequestID = request.ID; } else { response.RequestID = ""; } response.Data = data; return(response); }
/// <summary> /// 按错误数据创建输出对象 /// </summary> /// <param name="errorMsg"></param> /// <returns></returns> public static KingResponse GetErrorResponse(string errorMsg, KingRequest request = null) { KingResponse response = new KingResponse(); response.Success = false; response.ErrorMsg = errorMsg; if (request != null) { response.RequestID = request.ID; } else { response.RequestID = ""; } response.Data = null; return(response); }
/// <summary> /// 按错误数据获取错误输出字符串 /// </summary> /// <param name="errorMsg"></param> /// <returns></returns> public static string GetErrorResponseString(string errorMsg, KingRequest request = null) { return(JsonHelper.EncodeJson(GetErrorResponse(errorMsg, request))); }