public async Task Page() { var repo = BlogService.PageService; await repo.TestStatus(); foreach (var item in PageData) { await repo.TestGet(item.Id); } foreach (var id in await repo.TestAll()) { Assert.IsTrue(PageData.Any(x => x.Id == id)); } /*{ * var c = PageData.First().Route; * var res = await repo.Query(new AcBlog.Data.Models.Actions.PageQueryRequest * { * Route = c * }); * Assert.IsTrue(res.CurrentPage.TotalCount > 0); * * var filter = await repo.CreateRouteFilter().Filter(c); * filter.ShouldDeepEqual(res); * }*/ }
private PageMsg <T> GetPageInfo() { if (null == PageData || !PageData.Any()) { return(this); } //计算当前页码 CurrentPage = CurrentPage < 1 ? 1 : CurrentPage; //计算页容量 EachPageDataCount = EachPageDataCount < 1 ? 20 : EachPageDataCount; //计算最大页数 TotalPage = (int)Math.Ceiling(Total * 1.0 / EachPageDataCount); //最大页区间 int maxPageSpan = 2; //计算当前页之前的开始页码 if (CurrentPage == TotalPage) { PrevPage = CurrentPage - (maxPageSpan * 2); } else { PrevPage = CurrentPage - maxPageSpan; } //防止变负数 PrevPage = PrevPage > 1 ? PrevPage : 1; //计算当前页之后的结束页码 AfterPage = PrevPage + (maxPageSpan * 2); //防止超过最大页数 AfterPage = AfterPage > TotalPage ? TotalPage : AfterPage; return(this); }