gorm_page

package module
v0.0.0-...-75a1acf Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 17, 2023 License: Apache-2.0 Imports: 1 Imported by: 0

README

gorm分页

Usage
go get github.com/caijian-fighter/[email protected]

Data Wrap
Api Wrap
    {
        "code": 0,
        "msg": "",
        "data": {
            "page_size": 10,
            "page_no": 1,
            "total": 100,
            "list":[{},{}]
        }
    }

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Paginate

func Paginate[T any](page *Page[T]) func(db *gorm.DB) *gorm.DB

Types

type Page

type Page[T any] struct {
	PageNo   int64 `json:"page_no"`
	PageSize int64 `json:"page_size"`
	Total    int64 `json:"total"` // 总记录数
	Pages    int64 `json:"pages"` // 总页数
	List     []T   `json:"list"`  // 实际的list数据
}

func (*Page[T]) SelectPages

func (page *Page[T]) SelectPages(query *gorm.DB) (e error)

type User

type User struct {
	UserId int64  `gorm:"user_id"`
	Email  string `gorm:"email"`
	Mobile string `gorm:"mobile"`
}

func (*User) TableName

func (u *User) TableName() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL