diff --git a/database/model/base.go b/database/model/base.go index 1ac7194..5df2ccd 100644 --- a/database/model/base.go +++ b/database/model/base.go @@ -8,9 +8,9 @@ import ( // BaseModel 基础模型,包含自定义的创建时间和更新时间 type BaseModel struct { - Id int `json:"id" gorm:"column:id;primaryKey;autoIncrement;common:主键ID"` // 主键 ID - CreateTime time.Time `gorm:"column:create_time;type:datetime;not null" json:"created_at"` // 创建时间 - UpdateTime time.Time `gorm:"column:update_time;type:datetime;not null" json:"updated_at"` // 更新时间 + Id int `json:"id" gorm:"column:id;primaryKey;autoIncrement;common:主键ID"` // 主键 ID + CreateTime time.Time `json:"create_time" gorm:"column:create_time;type:datetime;autoCreateTime;common:创建时间"` + UpdateTime time.Time `json:"update_time" gorm:"column:update_time;type:datetime;autoUpdateTime;common:更新时间"` } // BeforeCreate 创建前自动设置时间