Files
QYZH.InteractiveMagazine/QYZH.InteractiveMagazine.Models/Dto/PageQueryModel.cs

58 lines
1.2 KiB
C#
Raw Normal View History

2026-06-01 13:42:40 +08:00
namespace QYZH.InteractiveMagazine.Models.Dto;
/// <summary>
/// 通用分页查询类
2026-06-01 13:42:40 +08:00
/// </summary>
public class PageQueryModel
{
/// <summary>
///当前页
2026-06-01 13:42:40 +08:00
/// </summary>
public int PageIndex { get; set; } = 1;
/// <summary>
///每页条数
2026-06-01 13:42:40 +08:00
/// </summary>
public int PageSize { get; set; } = 10;
/// <summary>
/// 排序字段
/// </summary>
public string Sort { get; set; } = string.Empty;
/// <summary>
/// 排序类型,前端传入的是"ascending""descending"
/// </summary>
public string SortType { get; set; } = string.Empty;
2026-06-01 13:42:40 +08:00
/// <summary>
/// 关键字
2026-06-01 13:42:40 +08:00
/// </summary>
public string? KeyWord { get; set; }
}
/// <summary>
/// 分页查询泛型类
/// </summary>
/// <typeparam name="T">查询参数类型</typeparam>
public class PageQueryModel<T> : PageQueryModel where T : class, new()
{
/// <summary>
/// 查询参数
/// </summary>
public T Params { get; set; } = new T();
public TP ConvertTo<TP>() where TP : class
{
if (Params != null)
{
return Params as TP;
}
return default;
}
public int Start => (PageIndex - 1) * PageSize + 1;
public int End => PageIndex * PageSize;
2026-06-01 13:42:40 +08:00
}