83 lines
2.2 KiB
C#
83 lines
2.2 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Text;
|
|
|
|
namespace Mini.Model.CrmModel
|
|
{
|
|
public class retMsg
|
|
{
|
|
public bool result { get; set; }
|
|
public int retcode { get; set; }
|
|
public string retmsg { get; set; }
|
|
public void SetFail(string msg, int code)
|
|
{
|
|
this.result = false;
|
|
this.retcode = code;
|
|
this.retmsg = msg;
|
|
}
|
|
public void SetResult(ApiResult result)
|
|
{
|
|
this.result = result.success;
|
|
this.retcode = result.code;
|
|
this.retmsg = result.msg;
|
|
}
|
|
|
|
public void SetResult(bool success, int code, string msg)
|
|
{
|
|
this.result = success;
|
|
this.retcode = code;
|
|
this.retmsg = msg;
|
|
}
|
|
}
|
|
|
|
public class retMsg<T>
|
|
{
|
|
public bool result { get; set; }
|
|
public int retcode { get; set; }
|
|
public string retmsg { get; set; }
|
|
/// <summary>
|
|
/// 数据
|
|
/// </summary>
|
|
public T retData { get; set; }
|
|
public Laypage retpage { get; set; }
|
|
|
|
public void SetFail(string msg, int code)
|
|
{
|
|
this.result = false;
|
|
this.retcode = code;
|
|
this.retmsg = msg;
|
|
}
|
|
public void SetResult(ApiResult result)
|
|
{
|
|
this.result = result.success;
|
|
this.retcode = result.code;
|
|
if (result.success)
|
|
{
|
|
Type t = typeof(T);
|
|
if (t == typeof(string))
|
|
{
|
|
this.retData = result.data;
|
|
}
|
|
else if (t == typeof(int))
|
|
{
|
|
this.retData = result.data;
|
|
}
|
|
else if (t == typeof(long))
|
|
{
|
|
this.retData = result.data;
|
|
}
|
|
else if (result.data != null)
|
|
{
|
|
this.retData = result.data.ToObject<T>();
|
|
}
|
|
if (result.page != null)
|
|
{
|
|
this.retpage = result.page;
|
|
}
|
|
}
|
|
else
|
|
this.retmsg = result.msg;
|
|
}
|
|
}
|
|
}
|