Skip to content

Commit

Permalink
Merge pull request #122 from Zzzzjle/fix-pageData
Browse files Browse the repository at this point in the history
PageData.cs:修复 PagedData 无法正确序列化问题;添加新增 `Empty` 属性用于获取默认实例
  • Loading branch information
witskeeper authored Dec 13, 2024
2 parents 70f03da + 97a90e8 commit 9b1f7d0
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions src/NetCorePal.Extensions.Dto/PagedData.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System.Text.Json.Serialization;

namespace NetCorePal.Extensions.Dto;
namespace NetCorePal.Extensions.Dto;

/// <summary>
/// 分页数据模型
Expand All @@ -15,7 +13,6 @@ public class PagedData<T>
/// <param name="total">总数据条数</param>
/// <param name="pageIndex">当前页码,从1开始</param>
/// <param name="pageSize">每页条数</param>
[JsonConstructor]
public PagedData(IEnumerable<T> items, int total, int pageIndex, int pageSize)
{
Items = items;
Expand All @@ -24,10 +21,10 @@ public PagedData(IEnumerable<T> items, int total, int pageIndex, int pageSize)
PageSize = pageSize;
}

public PagedData()
{
Items = [];
}
/// <summary>
/// 表示一个空的 <see cref="PagedData{T}"/> 实例。
/// </summary>
public static PagedData<T> Empty => new([], 0, 0, 0);

/// <summary>
/// 分页数据
Expand Down

0 comments on commit 9b1f7d0

Please sign in to comment.