文件管理增加数据库表。

This commit is contained in:
2026-08-18 17:29:06 +08:00
parent f1780de632
commit f1a6c5abaa
6 changed files with 157 additions and 98 deletions
+22
View File
@@ -262,3 +262,25 @@ type Page struct {
func (Page) TableName() string {
return "pages"
}
// ==================== 文件模型 ====================
// File 上传文件记录
type File struct {
ID uint `gorm:"primaryKey" json:"id"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
UserID uint `gorm:"index;not null" json:"user_id"` // 上传者
User User `gorm:"foreignKey:UserID" json:"user"` // 上传者信息
FileName string `gorm:"size:255;not null" json:"file_name"` // 存储文件名
OrigName string `gorm:"size:255" json:"orig_name"` // 原始文件名
FilePath string `gorm:"size:500;not null" json:"file_path"` // 相对存储路径(含年月目录)
FileSize int64 `gorm:"default:0" json:"file_size"` // 文件大小(字节)
MimeType string `gorm:"size:100" json:"mime_type"` // MIME 类型
}
// TableName 指定表名
func (File) TableName() string {
return "files"
}