|
PackageCom. bjsxt. pojo;
ImportJava. util. List;
Public ClassPagination <T> {
// Current page number
Private IntPage;
// How many data entries are displayed on each page
Private IntSize;
// Total number of records
Private IntTotalCount;
// Total number of pages
Private IntTotalPage;
// Start position of each query
Private IntStart;
// Whether the previous page exists
Private BooleanHasPrev;
// Previous Page
Private IntPrevPage;
// Whether the next page exists
Private BooleanHasNext;
// Next page
Private IntNextPage;
// Homepage
Private IntFirstPage;
// Last page
Private IntLastPage;
// Number of paging navigation Blocks
Private IntNavCount;
// Start position of the navigation
Private IntNavBegin;
// End position of the navigation
Private IntNavEnd;
// List set corresponding to the query result
PrivateList <T> list;
PublicPagination (String page, String size,IntTotalCount ){
// Current page number
This. Page =Null! = Page? Integer.ParseInt(Page): 1;
// How many data entries are displayed on each page
This. Size =Null! = Size? Integer.ParseInt(Size): 10;
// Total number of records
This. TotalCount = totalCount;
// Total number of pages
This. TotalPage = (Int) Math.Ceil(This. TotalCount * 1.0/This. Size );
// The current page number cannot exceed the total page number
If(This. Page>This. TotalPage &&This. TotalPage> 0 ){
This. Page =This. TotalPage;
}
// Start position of each query
This. Start = (This. Page-1 )*This. Size;
If(This. Page> 1 ){
// Whether the previous page exists
This. HasPrev =True;
// Previous Page
This. PrevPage =This. Page-1;
}
If(This. Page <This. TotalPage ){
// Whether the next page exists
This. HasNext =True;
// Next page
This. NextPage =This. Page + 1;
}
// Homepage
This. FirstPage = 1;
// Last page
This. LastPage =This. TotalPage;
// Number of paging navigation Blocks
This. NavCount = 10;
// Start position of the navigation
// If (this. page> this. totalPage-this. navCount ){
// This. navBegin = this. totalPage-this. navCount + 1;
//} Else {
This. NavBegin =This. Page-This. NavCount/2 <1? 1:This. Page-This. NavCount/2;
//}
// End position of the navigation
This. NavEnd =This. NavBegin +This. NavCount-1>This. TotalPage?This. TotalPage
:This. NavBegin +This. NavCount-1;
}
// The getter and setter methods are omitted.
}
|