模型绑定最佳实践

This commit is contained in:
administrator committed 2024-04-04 07:43:24 +08:00
1 parent 40e307faef
commit 5516bb80dd
12 files changed
+196 -14

No files matched your search

@@ -0,0 +1,7 @@
namespace HelloShop.ServiceDefaults.Constants;
public class PagingConstants
{
public const int DefaultPageSize = 10;
}
@@ -0,0 +1,6 @@
namespace HelloShop.ServiceDefaults.Models.Paging;
public class KeywordSearchRequest : PagedAndSortedRequest
{
public string? Keyword { get; init; }
}
@@ -0,0 +1,6 @@
namespace HelloShop.ServiceDefaults.Models.Paging;
public class PagedAndSortedRequest : PagedRequest
{
public IEnumerable<SortingOrder>? Sorts { get; init; }
}
@@ -0,0 +1,10 @@
using HelloShop.ServiceDefaults.Constants;
namespace HelloShop.ServiceDefaults.Models.Paging;
public class PagedRequest
{
public int PageNumber { get; init; } = 1;
public int PageSize { get; init; } = PagingConstants.DefaultPageSize;
}
@@ -0,0 +1,8 @@
namespace HelloShop.ServiceDefaults.Models.Paging;
public class PagedResponse<T>(IReadOnlyList<T> items, int totalCount)
{
public IReadOnlyList<T> Items { get; init; } = items;
public int TotalCount { get; init; } = totalCount;
}
@@ -0,0 +1,8 @@
namespace HelloShop.ServiceDefaults.Models.Paging;
public class SortingOrder
{
public required string PropertyName { get; init; }
public bool Ascending { get; init; }
}