model

package
v0.0.0-...-d140a6e Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2021 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Model

type Model struct {
	Id        int            `json:"id,omitempty" gorm:"column:id;type:INT UNSIGNED AUTO_INCREMENT;primary_key;" comment:"主键标识"`
	CreatedAt Time           `json:"created_at,omitempty" gorm:"column:created_at" comment:"创建时间"`
	UpdatedAt Time           `json:"updated_at,omitempty" gorm:"column:updated_at" comment:"更新时间"`
	DeletedAt gorm.DeletedAt `json:"-" gorm:"column:deleted_at;index" comment:"删除时间"`
}

type Time

type Time struct {
	time.Time
}

func (Time) MarshalJSON

func (t Time) MarshalJSON() ([]byte, error)

func (*Time) Scan

func (t *Time) Scan(v interface{}) error

Scan 为 Time 实现 Scan 方法,读取数据库时会调用该方法将时间数据转换成自定义时间类型;

func (*Time) UnmarshalJSON

func (t *Time) UnmarshalJSON(data []byte) error

UnmarshalJSON 为 Time 重写 MarshaJSON 和 UnmarshalJSON 方法,在此方法中实现自定义格式的转换;

func (Time) Value

func (t Time) Value() (driver.Value, error)

Value 为 Time 实现 Value 方法,写入数据库时会调用该方法将自定义时间类型转换并写入数据库;

Jump to

Keyboard shortcuts

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