refactor(database): 更新基础模型的时间字段配置
- 修改 CreateTime 字段的 JSON 标签从 created_at 到 create_time - 修改 UpdateTime 字段的 JSON 标签从 updated_at 到 update_time - 添加 autoCreateTime 和 autoUpdateTime GORM 标签实现自动时间戳 - 移除手动时间设置的相关注释 - 统一字段标签格式为 common 格式main v1.0.1023
parent
80ad00f98d
commit
7b6026950a
|
|
@ -9,8 +9,8 @@ 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"` // 更新时间
|
||||
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 创建前自动设置时间
|
||||
|
|
|
|||
Loading…
Reference in New Issue