1 Calculate based on the incoming parameters
1.1 Request parameters ( currPage : current page, pageSize : number of displayed items per page), calculate the starting number and ending number of items according to these two parameters
-
Starting number
firstIndex = (currPage-1) * pageSize
-
Deadline number
lastIndex = currPage * pageSize
1.2 Calculate the total page number (to get the total number)
pages = total%pageSize == 0 ? total/pageSize: total/pageSize + 1