wood chen aeb05f790a 重构数据库层并迁移到 GORM
- 将数据库操作从原生 SQL 迁移到 GORM ORM
- 更新模型定义,添加 GORM 标签和关系
- 移除手动创建表的 SQL 方法,改用 AutoMigrate
- 更新所有数据库相关处理逻辑以适配 GORM
- 升级 Go 版本和依赖库
- 移除数据库和路由中间件,简化项目结构
2025-03-06 23:32:18 +08:00

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"
}