//通过页码尺寸和当前页码以及总数据条数,获取limit,offset
//20,2,34
func ToLimitOffset(sizeIn string, indexIn string, count int) (limit int, offset int) {
size, _ := strconv.Atoi(sizeIn)
index, _ := strconv.Atoi(indexIn)
//1
if count == 0 {
return size, 0
}
var pageMax int
//1%10
if count%size == 0 {
pageMax = count / size
} else {
//1
pageMax = count/size + 1
}
if pageMax <= index {
index = pageMax
}
offset = size * (index - 1)
if offset == -10 {
offset = 0
}
return size, offset
}