You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
149 lines
4.2 KiB
C#
149 lines
4.2 KiB
C#
using NPOI.SS.Formula.Functions;
|
|
|
|
namespace djy.Model
|
|
{
|
|
/// <summary>
|
|
/// 通用返回信息类
|
|
/// </summary>
|
|
public class MessageModel<T>
|
|
{
|
|
/// <summary>
|
|
/// 状态码
|
|
/// </summary>
|
|
public int code { get; set; } = 200;
|
|
/// <summary>
|
|
/// 操作是否成功
|
|
/// </summary>
|
|
public bool success { get; set; } = false;
|
|
/// <summary>
|
|
/// 返回信息
|
|
/// </summary>
|
|
public string message { get; set; } = "";
|
|
/// <summary>
|
|
/// 开发者信息
|
|
/// </summary>
|
|
public string msgDev { get; set; }
|
|
/// <summary>
|
|
/// 返回数据集合
|
|
/// </summary>
|
|
public T data { get; set; }
|
|
|
|
/// <summary>
|
|
/// 返回成功
|
|
/// </summary>
|
|
/// <param name="msg">消息</param>
|
|
/// <returns></returns>
|
|
public static MessageModel<T> Success(string msg)
|
|
{
|
|
return Message(true, msg, default);
|
|
}
|
|
/// <summary>
|
|
/// 返回成功
|
|
/// </summary>
|
|
/// <param name="msg">消息</param>
|
|
/// <param name="data">数据</param>
|
|
/// <returns></returns>
|
|
public static MessageModel<T> Success(string msg, T data)
|
|
{
|
|
return Message(true, msg, data);
|
|
}
|
|
/// <summary>
|
|
/// 返回失败
|
|
/// </summary>
|
|
/// <param name="msg">消息</param>
|
|
/// <returns></returns>
|
|
public static MessageModel<T> Fail(string msg)
|
|
{
|
|
return Message(false, msg, default);
|
|
}
|
|
/// <summary>
|
|
/// 返回失败
|
|
/// </summary>
|
|
/// <param name="msg">消息</param>
|
|
/// <param name="data">数据</param>
|
|
/// <returns></returns>
|
|
public static MessageModel<T> Fail(string msg, T data)
|
|
{
|
|
return Message(false, msg, data);
|
|
}
|
|
/// <summary>
|
|
/// 返回消息
|
|
/// </summary>
|
|
/// <param name="success">失败/成功</param>
|
|
/// <param name="msg">消息</param>
|
|
/// <param name="data">数据</param>
|
|
/// <returns></returns>
|
|
private static MessageModel<T> Message(bool success, string msg, T data)
|
|
{
|
|
return new MessageModel<T>() { message = msg, data = data, success = success };
|
|
}
|
|
}
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public class MessageModel
|
|
{
|
|
/// <summary>
|
|
/// 状态码
|
|
/// </summary>
|
|
public int code { get; set; } = 200;
|
|
/// <summary>
|
|
/// 操作是否成功
|
|
/// </summary>
|
|
public bool success { get; set; } = false;
|
|
/// <summary>
|
|
/// 返回信息
|
|
/// </summary>
|
|
public string message { get; set; } = "";
|
|
/// <summary>
|
|
/// 返回数据集合
|
|
/// </summary>
|
|
public object data { get; set; }
|
|
|
|
|
|
/// <summary>
|
|
/// 返回成功
|
|
/// </summary>
|
|
/// <param name="msg">消息</param>
|
|
/// <returns></returns>
|
|
public static MessageModel Success(string msg)
|
|
{
|
|
return Message(true, msg, default);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 返回成功
|
|
/// </summary>
|
|
/// <param name="msg">消息</param>
|
|
/// <param name="data">数据</param>
|
|
/// <returns></returns>
|
|
public static MessageModel Success(string msg, object data)
|
|
{
|
|
return Message(true, msg, data);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 返回失败
|
|
/// </summary>
|
|
/// <param name="msg">消息</param>
|
|
/// <returns></returns>
|
|
public static MessageModel Fail(string msg)
|
|
{
|
|
return Message(false, msg, default);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 返回消息
|
|
/// </summary>
|
|
/// <param name="success">失败/成功</param>
|
|
/// <param name="msg">消息</param>
|
|
/// <param name="data">数据</param>
|
|
/// <returns></returns>
|
|
private static MessageModel Message(bool success, string msg, object data)
|
|
{
|
|
return new MessageModel() { message = msg, data = data, success = success };
|
|
}
|
|
}
|
|
|
|
}
|