代码拉取完成,页面将自动刷新
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package zorm
// Page 分页对象
// Page Pagination object
type Page struct {
// 当前页码,从1开始
// Current page number, starting from 1
PageNo int `json:"pageNo,omitempty"`
// 每页多少条,默认20条
// How many items per page, 20 items by default
PageSize int `json:"pageSize,omitempty"`
// 数据总条数
// Total number of data
TotalCount int `json:"totalCount,omitempty"`
// 共多少页
// How many pages
PageCount int `json:"pageCount,omitempty"`
// 是否是第一页
// Is it the first page
FirstPage bool `json:"firstPage,omitempty"`
// 是否有上一页
// Whether there is a previous page
HasPrev bool `json:"hasPrev,omitempty"`
// 是否有下一页
// Is there a next page
HasNext bool `json:"hasNext,omitempty"`
// 是否是最后一页
// Is it the last page
LastPage bool `json:"lastPage,omitempty"`
}
// NewPage 创建Page对象
// NewPage Create Page object
func NewPage() *Page {
page := Page{}
page.PageNo = 1
page.PageSize = 20
return &page
}
// setTotalCount 设置总条数,计算其他值
// setTotalCount Set the total number of bars, calculate other values
func (page *Page) setTotalCount(total int) {
page.TotalCount = total
page.PageCount = (page.TotalCount + page.PageSize - 1) / page.PageSize
if page.PageNo >= page.PageCount {
page.LastPage = true
} else {
page.HasNext = true
}
if page.PageNo > 1 {
page.HasPrev = true
} else {
page.FirstPage = true
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。