feat(common): 升级 gf 框架版本至 v2.8.0 并优化模型时间字段
- 将 `github.com/gogf/gf/contrib/drivers/pgsql/v2` 和 redis 依赖从 v2.6.3 升级到 v2.8.0
- 使用 `*gtime.Time` 替代标准库 `time.Time` 以支持更灵活的时间处理
- 移除 Model 结构体中 CreateTime、UpdateTime 等字段的默认初始化逻辑
- 注释掉已弃用的 GDBM 函数,推荐使用 DBM
- 在 DBM 中添加 OnConflict("id") 配置以增强写入安全性
- 调整部分代码结构与调用方式以适配新版框架行为
```
38 lines
892 B
Go
38 lines
892 B
Go
package cool
|
|
|
|
import (
|
|
"github.com/gogf/gf/v2/os/gtime"
|
|
)
|
|
|
|
type IModel interface {
|
|
TableName() string
|
|
GroupName() string
|
|
}
|
|
|
|
type UserModel interface {
|
|
GetData() string
|
|
SetData(data string)
|
|
TableName() string
|
|
GroupName() string
|
|
}
|
|
type Model struct {
|
|
ID uint `gorm:"primaryKey" json:"id"`
|
|
CreateTime *gtime.Time ` gorm:"column:createTime;not null;index,priority:1;autoCreateTime:nano;comment:创建时间" json:"createTime"` // 创建时间
|
|
UpdateTime *gtime.Time ` gorm:"column:updateTime;not null;index,priority:1;autoUpdateTime:nano;comment:更新时间" json:"updateTime"` // 更新时间
|
|
DeletedAt *gtime.Time `gorm:"index" json:"deletedAt"`
|
|
}
|
|
|
|
// 返回表名
|
|
func (m *Model) TableName() string {
|
|
return "this_table_should_not_exist"
|
|
}
|
|
|
|
// 返回分组名
|
|
func (m *Model) GroupName() string {
|
|
return "default"
|
|
}
|
|
|
|
func NewModel() *Model {
|
|
return &Model{}
|
|
}
|