🎨 优化model和日志,完善配置文件
parent
8c5fa60081
commit
6945e6db93
@ -1,20 +1,20 @@
|
|||||||
package types
|
package types
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/google/uuid"
|
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
// BaseDbModel 数据库通用字段
|
// BaseDbModel 数据库通用字段
|
||||||
type BaseDbModel struct {
|
type BaseDbModel struct {
|
||||||
Id string `json:"id" gorm:"type:varchar(50);primarykey"`
|
ID uint `gorm:"type:int(11);primarykey;" json:"id"`
|
||||||
CreatedAt DateTime `json:"createdAt"`
|
CreatedAt time.Time `json:"created_at"`
|
||||||
UpdatedAt DateTime `json:"updatedAt"`
|
UpdatedAt time.Time `json:"updated_at"`
|
||||||
DeletedAt gorm.DeletedAt `json:"-" gorm:"index:deleted"`
|
DeletedAt gorm.DeletedAt `json:"-" gorm:"index:deleted"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// BeforeCreate 创建数据库对象之前生成UUID
|
/*// BeforeCreate 创建数据库对象之前生成UUID
|
||||||
func (m *BaseDbModel) BeforeCreate(*gorm.DB) (err error) {
|
func (m *BaseDbModel) BeforeCreate(*gorm.DB) (err error) {
|
||||||
m.Id = uuid.New().String()
|
m.Id = uuid.New().String()
|
||||||
return
|
return
|
||||||
}
|
}*/
|
||||||
|
Loading…
Reference in New Issue