feat: file upload and download
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
package models
|
||||
|
||||
import "gorm.io/gorm"
|
||||
|
||||
type AppFileType string
|
||||
|
||||
const (
|
||||
AppFileTypeLessonPlan AppFileType = "lesson_plan"
|
||||
)
|
||||
|
||||
type AppFile struct {
|
||||
gorm.Model
|
||||
FileType AppFileType `gorm:"type:varchar(64);not null;index" json:"fileType"`
|
||||
OriginalFilename string `gorm:"size:255;not null" json:"originalFilename"`
|
||||
StoredFilename string `gorm:"size:255;not null;uniqueIndex" json:"storedFilename"`
|
||||
FilePath string `gorm:"size:1024;not null" json:"filePath"`
|
||||
ContentType string `gorm:"size:255;not null" json:"contentType"`
|
||||
FileSize int64 `gorm:"not null" json:"fileSize"`
|
||||
MD5 string `gorm:"size:32;not null;uniqueIndex" json:"md5"`
|
||||
UploaderID uint `gorm:"not null;index" json:"uploaderId"`
|
||||
UploaderName string `gorm:"size:255;not null;index" json:"uploaderName"`
|
||||
DownloadCount int64 `gorm:"not null;default:0" json:"downloadCount"`
|
||||
LastDownloadAt *int64 `gorm:"type:bigint;index" json:"lastDownloadAt"`
|
||||
}
|
||||
|
||||
func (AppFile) TableName() string {
|
||||
return "app_files"
|
||||
}
|
||||
Reference in New Issue
Block a user