You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
105 lines
3.2 KiB
105 lines
3.2 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Text;
|
|
|
|
namespace Shentun.Peis
|
|
{
|
|
|
|
public interface ICustomerReturnValue
|
|
{
|
|
|
|
}
|
|
public class CustomerReturnValue : ICustomerReturnValue
|
|
{
|
|
public int code { get; set; }
|
|
public string message { get; set; }
|
|
public object data { get; set; }
|
|
private CustomerReturnValue()
|
|
{
|
|
|
|
}
|
|
|
|
public static CustomerReturnValue CreateInstance(int code, string message, object obj)
|
|
{
|
|
CustomerReturnValue returnValue = new CustomerReturnValue();
|
|
returnValue.code = code;
|
|
returnValue.message = message;
|
|
returnValue.data = obj;
|
|
return returnValue;
|
|
}
|
|
|
|
public static CustomerReturnValue CreateSuccessInstance()
|
|
{
|
|
CustomerReturnValue returnValue = new CustomerReturnValue();
|
|
returnValue.code = 1;
|
|
returnValue.message = "Success";
|
|
returnValue.data = null;
|
|
return returnValue;
|
|
}
|
|
|
|
public static CustomerReturnValue CreateSuccessInstance(Object obj)
|
|
{
|
|
CustomerReturnValue returnValue = new CustomerReturnValue();
|
|
returnValue.code = 1;
|
|
returnValue.message = "Success";
|
|
returnValue.data = obj;
|
|
return returnValue;
|
|
}
|
|
|
|
public static CustomerReturnValue CreateNotFoundInstance()
|
|
{
|
|
CustomerReturnValue returnValue = new CustomerReturnValue();
|
|
returnValue.code = 0;
|
|
returnValue.message = "无数据";
|
|
returnValue.data = null;
|
|
return returnValue;
|
|
}
|
|
|
|
public static CustomerReturnValue CreateErrorInstance(string message)
|
|
{
|
|
CustomerReturnValue returnValue = new CustomerReturnValue();
|
|
returnValue.code = -1;
|
|
returnValue.message = message;
|
|
returnValue.data = null;
|
|
return returnValue;
|
|
}
|
|
|
|
|
|
public static CustomerReturnValue CreateErrorInstance(int code, string messsage)
|
|
{
|
|
CustomerReturnValue returnValue = new CustomerReturnValue();
|
|
returnValue.code = code;
|
|
returnValue.message = messsage;
|
|
returnValue.data = null;
|
|
return returnValue;
|
|
}
|
|
|
|
public static CustomerReturnValue CreateDataBaseErrorInstance(string message)
|
|
{
|
|
CustomerReturnValue returnValue = new CustomerReturnValue();
|
|
returnValue.code = -2;
|
|
returnValue.message = "数据库错误:" + message;
|
|
returnValue.data = null;
|
|
return returnValue;
|
|
}
|
|
|
|
#region 自定义
|
|
|
|
/// <summary>
|
|
/// 状态0的返回值 自定义
|
|
/// </summary>
|
|
/// <param name="obj"></param>
|
|
/// <param name="message"></param>
|
|
/// <returns></returns>
|
|
public static CustomerReturnValue CreateCustomErrorInstance(Object obj, string message)
|
|
{
|
|
CustomerReturnValue returnValue = new CustomerReturnValue();
|
|
returnValue.code = 0;
|
|
returnValue.message = message;
|
|
returnValue.data = obj;
|
|
return returnValue;
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
}
|