文件管理增加数据库表。
This commit is contained in:
@@ -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"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user