Documentation ¶
Index ¶
- type Page
- type Pagination
- func (p Pagination) CurrentPage() int
- func (p Pagination) GetPageFromRequest(r *http.Request) int
- func (p Pagination) HasNext() bool
- func (p *Pagination) HasPages() bool
- func (p Pagination) HasPrev() bool
- func (p Pagination) NewPage(page int) Page
- func (p Pagination) NextPage() int
- func (p *Pagination) Paging() ViewData
- func (p Pagination) PrevPage() int
- func (p Pagination) Results(data interface{}) error
- func (p *Pagination) SetPage(page int)
- func (p *Pagination) TotalCount() int64
- func (p Pagination) TotalPage() int
- type ViewData
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Pagination ¶
type Pagination struct { BaseURL string PerPage int Page int Count int64 // contains filtered or unexported fields }
Pagination 分页对象
func New ¶
New 分页对象构建器 r —— 用来获取分页的 URL 参数,默认是 page,可通过 config/pagination.go 修改 db —— GORM 查询句柄,用以查询数据集和获取数据总数 baseURL —— 用以分页链接 PerPage —— 每页条数,传参为小于或者等于 0 时为默认值 10,可通过 config/pagination.go 修改
func (Pagination) GetPageFromRequest ¶
func (p Pagination) GetPageFromRequest(r *http.Request) int
GetPageFromRequest 从 URL 中获取 page 参数
func (Pagination) Results ¶
func (p Pagination) Results(data interface{}) error
Results 返回请求数据,请注意 data 参数必须为 GROM 模型的 Slice 对象
Click to show internal directories.
Click to hide internal directories.