Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CustomTime ¶
自定义时间类型,为了能够自定义时间类型的反序列化格式
func (CustomTime) MarshalJSON ¶
func (t CustomTime) MarshalJSON() ([]byte, error)
自定义时间类型的反序列化格式,可参考Go/src/time/time.go的MarshalJSON
func (*CustomTime) Scan ¶
func (t *CustomTime) Scan(value interface{}) error
实现 sql.Scanner 接口,Scan 将 value 扫描至 Jsonb
func (CustomTime) String ¶
func (t CustomTime) String() string
func (*CustomTime) UnmarshalJSON ¶
func (t *CustomTime) UnmarshalJSON(data []byte) error
自定义时间类型的序列化格式,可参考Go/src/time/time.go的UnmarshalJSON
type ExtraModel ¶
type ExtraModel struct { Name string `gorm:"column:name;comment:名称" json:"name" form:"name"` // 名称 IsEnable *bool `gorm:"column:is_enable;comment:是否启用" json:"isEnable" form:"isEnable"` // 是否启用 Sort *int64 `gorm:"column:sort;comment:排序" json:"sort" form:"sort"` // 排序 }
额外的通用模型,包含:名称,是否启用,排序
type Model ¶
type Model struct { Id int64 `gorm:"column:id;comment:Id;primarykey" json:"id" form:"id"` // Id CreateTime CustomTime `gorm:"column:create_time;comment:创建时间;<-:create" json:"createTime" form:"createTime"` // 创建时间,格式:yyyy-MM-dd HH:mm:ss UpdateTime CustomTime `gorm:"column:update_time;comment:修改时间" json:"updateTime" form:"updateTime"` // 修改时间,格式:yyyy-MM-dd HH:mm:ss DeleteTime gorm.DeletedAt `gorm:"column:delete_time;comment:删除时间;index" json:"-" form:"deleteTime"` // 删除时间,格式:yyyy-MM-dd HH:mm:ss }
通用模型,参考gorm.Model
func (*Model) BeforeCreate ¶
模型创建前的钩子,给创建时间和修改时间赋值
Click to show internal directories.
Click to hide internal directories.