Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct { Debug bool // 是否开启调试模式 Host string // 服务地址 Port string // 服务端口 User string // 用户名 Pass string // 密码 Name string // 数据库名称 Char string // 字符集 MaxIdleConns int // 最大空闲连接数 MaxOpenConns int // 最大打开连接数 MaxLifetime int // 连接最大生命周期 }
Config 数据库配置
type Model ¶
type Model struct { ID uint `gorm:"primarykey" json:"id"` // 主键ID CreatedAt time.Time `gorm:"not null" json:"created_at"` // 创建时间 UpdatedAt time.Time `gorm:"not null" json:"updated_at"` // 更新时间 DeletedAt gorm.DeletedAt `gorm:"index" json:"deleted_at,omitempty"` // 删除时间(软删除) }
Model 基础模型
type PageResult ¶
type PageResult struct { List interface{} `json:"list"` // 数据列表 Page int `json:"page"` // 当前页码 PageSize int `json:"page_size"` // 每页数量 Total int64 `json:"total"` // 总数据量 }
PageResult 分页结果
func GetPage ¶
func GetPage(db *gorm.DB, p *Pagination, data interface{}) (*PageResult, error)
GetPage 获取分页结果
type Pagination ¶
type Pagination struct { Page int `json:"page" form:"page"` // 当前页码 PageSize int `json:"page_size" form:"page_size"` // 每页数量 }
Pagination 分页参数
Click to show internal directories.
Click to hide internal directories.