| 12345678910111213141516171819202122232425262728293031323334 | package commontype PageParams struct {	Page     int64 `protobuf:"varint,1,opt,name=page,proto3" json:"page"`	PageSize int64 `protobuf:"varint,2,opt,name=pageSize,proto3" json:"pageSize"`	Total    int64 `protobuf:"varint,3,opt,name=total,proto3" json:"total"`	Last     bool  `protobuf:"varint,4,opt,name=last,proto3" json:"last"`}//GetPageParams 从0开始的分页func (this *PageParams) GetPageParams() (limit int, offset int) {	_offset := this.Page * this.PageSize	if this.Total <= this.PageSize {		this.Page = 0		this.Last = true		return int(this.Total), 0	}	_start := (this.Page + 1) * this.PageSize	if this.Total-_start < 0 {		this.Last = true		pageCount := this.Total / this.PageSize		this.Page = pageCount		num := this.Total - pageCount*this.PageSize		if num == 0 {			pageCount = pageCount - 1			return int(this.PageSize), int(pageCount * this.PageSize)		}		return int(num), int(pageCount * this.PageSize)	} else if this.Total-_start == 0 {		this.Last = true	}	return int(this.PageSize), int(_offset)}
 |