/// <summary>
/// 构造函数
/// </summary>
/// <param name="resultCode"></param>
/// <param name="resultMsg"></param>
/// <param name="obj"></param>
public ResultInfo(int resultCode, string resultMsg, T obj)
{
ResultCode = resultCode;
ResultMsg = resultMsg;
ResultObj = obj;
}
/// <summary>
/// 返回码
/// </summary>
private int resultCode;
public int ResultCode
{
get { return resultCode; }
set
{
this.resultCode = value;
if (Resource.Codes.ContainsKey(value))
{
if (this.ResultMsg == null || this.ResultMsg == "")
{
this.ResultMsg = Resource.Codes[value].cn;
}
}
}
}
返回统一调用:
正常返回:
return JsonHelper.ToJson(new ResultInfo<string>(0, "", “返回数据”));
错误返回:
return JsonHelper.ToJson(new ResultInfo<string>(-1, "错误码或者错误提示", “”));