文件上传数据库

This commit is contained in:
2025-07-09 21:34:52 +08:00
parent b9b53fdee7
commit b0924f8a7d
5 changed files with 71 additions and 45 deletions
+15
View File
@@ -12,6 +12,19 @@ import (
var DB *gorm.DB
var err error
type File_info struct {
ID uint `gorm:"primaryKey;autoIncrement"`
Name string `gorm:"not null;size:256;index"` // 前端报告的文件名
Path string `gorm:"not null;size:300"` //
Sha256 string `gorm:"not null;size:256;index"` //
Mime string `gorm:"size:64;index"`
Type string `gorm:"size:64;index"`
Const uint `gorm:"default:1;index"`
Per uint `gorm:"default:1"`
UserID uint `gorm:"not null;index"`
Date time.Time `gorm:"type:datetime;default:CURRENT_TIMESTAMP"` // 默认当前时间
}
type User struct {
ID uint `gorm:"primaryKey;autoIncrement"` // 自增主键
Name string `gorm:"size:100;uniqueIndex"` // 唯一约束索引
@@ -188,4 +201,6 @@ func Init_database() {
DB.AutoMigrate(&Ticket{})
DB.AutoMigrate(&File_info{})
}