|
|
@ -0,0 +1,103 @@
|
|
|
|
|
|
|
|
namespace HybirdFrameworkCore.Entity
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
|
|
/// 通用返回信息类
|
|
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
|
public class Result<T>
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
|
|
/// 状态码
|
|
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
|
public int Status { get; set; } = 200;
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
|
|
/// 操作是否成功
|
|
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
|
public bool IsSuccess { get; set; } = false;
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
|
|
/// 返回信息
|
|
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
|
public string? Msg { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
|
|
/// 返回数据集合
|
|
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
|
public T? Data { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
|
|
/// 返回成功
|
|
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
|
/// <param name="msg">消息</param>
|
|
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
|
|
public static Result<T> Success(string msg = "成功")
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return Message(true, msg, default);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
|
|
/// 返回成功
|
|
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
|
/// <param name="data">数据</param>
|
|
|
|
|
|
|
|
/// <param name="msg">消息</param>
|
|
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
|
|
public static Result<T> Success(T data, string msg = "成功")
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return Message(true, msg, data);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
|
|
/// 返回失败
|
|
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
|
/// <param name="msg">消息</param>
|
|
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
|
|
public static Result<T> Fail(string msg = "失败")
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return Message(false, msg, default);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
|
|
/// 返回失败
|
|
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
|
/// <param name="msg">消息</param>
|
|
|
|
|
|
|
|
/// <param name="data">数据</param>
|
|
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
|
|
public static Result<T> Fail(T data, string msg = "失败")
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return Message(false, msg, data);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
|
|
/// 返回消息
|
|
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
|
/// <param name="success">失败/成功</param>
|
|
|
|
|
|
|
|
/// <param name="msg">消息</param>
|
|
|
|
|
|
|
|
/// <param name="data">数据</param>
|
|
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
|
|
public static Result<T> Message(bool success, string msg, T data)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return new Result<T>() { Msg = msg, Data = data, IsSuccess = success };
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
|
|
/// 返回消息
|
|
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
|
/// <param name="success">失败/成功</param>
|
|
|
|
|
|
|
|
/// <param name="msg">消息</param>
|
|
|
|
|
|
|
|
/// <param name="data">数据</param>
|
|
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
|
|
public static Result<T> Message(bool success, T data)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return new Result<T>() { Msg="查询成功", Data = data, IsSuccess = success };
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|