model

package
v0.0.11 Latest Latest
Warning

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

Go to latest
Published: May 15, 2025 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AfterCreate

type AfterCreate interface {
	AfterCreate() error
}

AfterCreate 创建后钩子接口

type AfterDelete

type AfterDelete interface {
	AfterDelete() error
}

AfterDelete 删除后钩子接口

type AfterFind

type AfterFind interface {
	AfterFind() error
}

AfterFind 查询后钩子接口

type AfterSave

type AfterSave interface {
	AfterSave() error
}

AfterSave 保存后钩子接口

type AfterUpdate

type AfterUpdate interface {
	AfterUpdate() error
}

AfterUpdate 更新后钩子接口

type BeforeCreate

type BeforeCreate interface {
	BeforeCreate() error
}

BeforeCreate 创建前钩子接口

type BeforeDelete

type BeforeDelete interface {
	BeforeDelete() error
}

BeforeDelete 删除前钩子接口

type BeforeFind

type BeforeFind interface {
	BeforeFind() error
}

BeforeFind 查询前钩子接口

type BeforeSave

type BeforeSave interface {
	BeforeSave() error
}

BeforeSave 保存前钩子接口

type BeforeUpdate

type BeforeUpdate interface {
	BeforeUpdate() error
}

BeforeUpdate 更新前钩子接口

type JSON

type JSON json.RawMessage

JSON 自定义JSON类型

func (JSON) MarshalJSON

func (j JSON) MarshalJSON() ([]byte, error)

MarshalJSON 实现json.Marshaler接口

func (*JSON) Scan

func (j *JSON) Scan(value interface{}) error

Scan 实现sql.Scanner接口

func (*JSON) UnmarshalJSON

func (j *JSON) UnmarshalJSON(data []byte) error

UnmarshalJSON 实现json.Unmarshaler接口

func (JSON) Value

func (j JSON) Value() (driver.Value, error)

Value 实现driver.Valuer接口

type JSONArray

type JSONArray []interface{}

JSONArray JSON数组类型

func (*JSONArray) Scan

func (a *JSONArray) Scan(value interface{}) error

Scan 实现sql.Scanner接口

func (JSONArray) Value

func (a JSONArray) Value() (driver.Value, error)

Value 实现driver.Valuer接口

type JSONMap

type JSONMap map[string]interface{}

JSONMap JSON映射类型

func (*JSONMap) Scan

func (m *JSONMap) Scan(value interface{}) error

Scan 实现sql.Scanner接口

func (JSONMap) Value

func (m JSONMap) Value() (driver.Value, error)

Value 实现driver.Valuer接口

type Model

type Model struct {
	ID        uint       `gorm:"primary_key" json:"id"`
	CreatedAt time.Time  `json:"created_at"`
	UpdatedAt time.Time  `json:"updated_at"`
	DeletedAt *time.Time `sql:"index" json:"deleted_at,omitempty"`
}

Model 基础模型结构

type Pagination

type Pagination struct {
	Total    int64       `json:"total"`     // 总记录数
	Page     int         `json:"page"`      // 当前页码
	PageSize int         `json:"page_size"` // 每页记录数
	Data     interface{} `json:"data"`      // 数据
}

Pagination 分页结构

func NewPagination

func NewPagination(data interface{}, total int64, page, pageSize int) *Pagination

NewPagination 创建分页结构

func (*Pagination) GetLimit

func (p *Pagination) GetLimit() int

GetLimit 获取限制数

func (*Pagination) GetOffset

func (p *Pagination) GetOffset() int

GetOffset 获取偏移量

func (*Pagination) GetTotalPages

func (p *Pagination) GetTotalPages() int

GetTotalPages 获取总页数

func (*Pagination) HasNext

func (p *Pagination) HasNext() bool

HasNext 是否有下一页

func (*Pagination) HasPrevious

func (p *Pagination) HasPrevious() bool

HasPrevious 是否有上一页

type SoftDelete

type SoftDelete interface {
	SoftDelete() error
}

SoftDelete 软删除接口

type TableName

type TableName interface {
	TableName() string
}

TableName 表名接口

Jump to

Keyboard shortcuts

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