SOMS/YunDa.Application/YunDa.SOMS.DataTransferObject/PagedAndSortedResultRequestDto.cs

39 lines
1.0 KiB
C#
Raw Normal View History

using System.ComponentModel.DataAnnotations;
namespace YunDa.SOMS.DataTransferObject
{
/// <summary>
/// 分页和排序请求基础DTO
/// </summary>
public class PagedAndSortedResultRequestDto
{
/// <summary>
/// 页码从1开始
/// </summary>
[Range(1, int.MaxValue, ErrorMessage = "页码必须大于0")]
public int PageIndex { get; set; } = 1;
/// <summary>
/// 每页大小
/// </summary>
[Range(1, 1000, ErrorMessage = "每页大小必须在1-1000之间")]
public int PageSize { get; set; } = 20;
/// <summary>
/// 排序字段
/// 格式: "Name" 或 "Name DESC" 或 "Name ASC, Age DESC"
/// </summary>
public string Sorting { get; set; }
/// <summary>
/// 跳过的记录数
/// </summary>
public int SkipCount => (PageIndex - 1) * PageSize;
/// <summary>
/// 最大结果数
/// </summary>
public int MaxResultCount => PageSize;
}
}