🎨 优化model和日志,完善配置文件

This commit is contained in:
2022-05-26 23:53:18 +08:00
parent 8c5fa60081
commit 6945e6db93
13 changed files with 65 additions and 44 deletions

View File

@@ -1,20 +1,20 @@
package types
import (
"github.com/google/uuid"
"gorm.io/gorm"
"time"
)
// BaseDbModel 数据库通用字段
type BaseDbModel struct {
Id string `json:"id" gorm:"type:varchar(50);primarykey"`
CreatedAt DateTime `json:"createdAt"`
UpdatedAt DateTime `json:"updatedAt"`
ID uint `gorm:"type:int(11);primarykey;" json:"id"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
DeletedAt gorm.DeletedAt `json:"-" gorm:"index:deleted"`
}
// BeforeCreate 创建数据库对象之前生成UUID
/*// BeforeCreate 创建数据库对象之前生成UUID
func (m *BaseDbModel) BeforeCreate(*gorm.DB) (err error) {
m.Id = uuid.New().String()
return
}
}*/