mirror of
https://github.com/woodchen-ink/aimodels-prices.git
synced 2025-07-18 21:51:59 +08:00
- 将数据库操作从原生 SQL 迁移到 GORM ORM - 更新模型定义,添加 GORM 标签和关系 - 移除手动创建表的 SQL 方法,改用 AutoMigrate - 更新所有数据库相关处理逻辑以适配 GORM - 升级 Go 版本和依赖库 - 移除数据库和路由中间件,简化项目结构
23 lines
563 B
Go
23 lines
563 B
Go
package models
|
|
|
|
import (
|
|
"time"
|
|
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
type Provider struct {
|
|
ID uint `json:"id" gorm:"primaryKey"`
|
|
Name string `json:"name" gorm:"not null"`
|
|
Icon string `json:"icon"`
|
|
CreatedAt time.Time `json:"created_at" gorm:"autoCreateTime"`
|
|
UpdatedAt time.Time `json:"updated_at" gorm:"autoUpdateTime"`
|
|
CreatedBy string `json:"created_by" gorm:"not null"`
|
|
DeletedAt gorm.DeletedAt `json:"-" gorm:"index"`
|
|
}
|
|
|
|
// TableName 指定表名
|
|
func (Provider) TableName() string {
|
|
return "provider"
|
|
}
|