using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace HH.WMS.Common.Response { public class CommResponse { public bool success { get; private set; } public string errCode { get; private set; } public string errMsg { get; private set; } /// /// 返回错误 /// /// /// public static CommResponse Error(string msg) { var result = new CommResponse(); result.success = false; result.errMsg = msg; result.errCode = EnumValue(ErrorEnum.SystemError); return result; } public static CommResponse Error(string msg, ErrorEnum errCode) { var result = new CommResponse(); result.success = false; result.errMsg = msg; result.errCode = EnumValue(errCode); return result; } public static CommResponse Error(string msg, HH.WMS.Common.External.LogPara logPara) { var result = new CommResponse(); result.success = false; result.errMsg = msg; result.errCode = EnumValue(ErrorEnum.SystemError); Log.Detail(logPara, "结果异常,原因:" + msg); return result; } /// /// 返回错误 /// /// /// /// public static CommResponse Error(string msg, string className) { var result = new CommResponse(); result.success = false; result.errMsg = msg; result.errCode = EnumValue(ErrorEnum.SystemError); // Log.ApiDebug(className, msg); return result; } /// /// 返回正确 /// /// public static CommResponse Normal() { var result = new CommResponse(); result.success = true; result.errMsg = ""; result.errCode = EnumValue(ErrorEnum.Normal); return result; } public static CommResponse Normal(string msg) { var result = new CommResponse(); result.success = true; result.errMsg = msg; result.errCode = EnumValue(ErrorEnum.Normal); return result; } public string Describe() { return "结果:" + (success ? "成功!" : "失败!" + errMsg); } public static string EnumValue(ErrorEnum error) { return ((int)error).ToString(); } } }