http返回状态类,分页查询类

master
lxw 6 months ago
parent 6c88f5a0a5
commit 41c5e77097

@ -0,0 +1,13 @@
namespace HybirdFrameworkCore.Entity;
public class QueryPageModel
{
/// <summary>
///页码
/// </summary>
public int Page { get; set; } = 1;
/// <summary>
/// 页数
/// </summary>
public int PageSize { get; set; } = 10;
}

@ -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 };
}
}
}
Loading…
Cancel
Save