using System;
using System.Runtime.Serialization;
namespace Znyc.Recruitment.Admin.Commons.Entitys
{
///
/// 公共返回结果对象
///
[Serializable]
public class CommonResult
{
///
/// 错误代码
///
private string m_ErrCode = "-1";
///
/// 错误描述信息
///
private string m_ErrMsg;
///
/// 用来传递的object内容
///
[DataMember] private object m_ResData;
///
/// 成功或失败
///
private bool m_Success;
///
/// BaseResult构造函数
///
public CommonResult()
{
}
///
/// BaseResult构造函数
///
/// 错误消息
/// 错误代码
public CommonResult(string errmsg, string errcode)
{
ErrMsg = errmsg;
ErrCode = errcode;
}
///
/// 构造函数
///
/// 错误消息
/// 成功或失败
/// 错误代码
public CommonResult(string errmsg, bool success, string errcode)
{
ErrMsg = errmsg;
ErrCode = errcode;
Success = success;
}
///
/// 错误代码
///
[DataMember]
public string ErrCode
{
get => m_ErrCode;
set
{
m_ErrCode = value;
if (value == "0")
{
Success = m_Success = true;
}
else
{
Success = m_Success = false;
}
}
}
///
/// 如果不成功,返回的错误描述信息
///
[DataMember]
public string ErrMsg
{
get => m_ErrMsg;
set => m_ErrMsg = value;
}
///
/// 成功返回true,失败返回false
///
[DataMember]
public bool Success
{
get
{
if (ErrCode == "0")
{
m_Success = true;
}
return m_Success;
}
set => m_Success = value;
}
///
/// 用来传递的object内容
///
[DataMember]
public object ResData
{
get => m_ResData;
set => m_ResData = value;
}
}
///
/// WEBAPI通用返回泛型基类
///
///
public class CommonResult : CommonResult
{
///
/// 回传的结果
///
public T Result { get; set; }
}
}