该函数返回页码的startIndex
, endIndex
func ArrPage(pageNumber, pageSize, totalCount int)(int,int){
totalPage := 0
if totalCount%pageSize == 0{
totalPage = totalCount/pageSize
}else{
totalPage = totalCount/pageSize+1
}
fmt.Println(totalPage)
if pageNumber < 1{
pageNumber = 1
}
startIndex := (pageNumber - 1) * pageSize
endIndex := startIndex + pageSize
if endIndex >= totalCount{
endIndex = totalCount
}
return startIndex, endIndex
}
网友评论