文件上传数据库
This commit is contained in:
@@ -1,26 +1,6 @@
|
||||
package models
|
||||
|
||||
//mime信息转换位拓展名
|
||||
var Mime_to_extname = map[string]string{
|
||||
|
||||
"image/jpeg": ".jpeg",
|
||||
"image/png": ".png",
|
||||
"image/gif": ".gif",
|
||||
"image/bmp": ".bmp",
|
||||
|
||||
"video/mp4": ".mp4",
|
||||
"video/x-msvideo": ".",
|
||||
"video/quicktime": ".",
|
||||
"video/x-flv": ".flv",
|
||||
"video/mpeg": ".mpeg",
|
||||
|
||||
"audio/mpeg": ".mp3",
|
||||
"audio/aac": ".acc",
|
||||
"audio/wav": ".wav",
|
||||
"audio/flac": ".flac",
|
||||
|
||||
"application/pdf": ".pdf",
|
||||
}
|
||||
|
||||
type Configs_web_t struct {
|
||||
Host string `mapstructure:"host"`
|
||||
@@ -41,8 +21,8 @@ type Configs_user_t struct {
|
||||
type Configs_file_t struct {
|
||||
Max_size uint64 `mapstructure:"max_size"`
|
||||
Pahts map[string]string `mapstructure:"pahts"`
|
||||
Allow_image_mime map[string]bool `mapstructure:"allow_image_mime"`
|
||||
Allow_video_mime map[string]bool `mapstructure:"allow_video_mime"`
|
||||
Allow_music_mime map[string]bool `mapstructure:"allow_music_mime"`
|
||||
Allow_pdf_mime map[string]bool `mapstructure:"allow_pdf_mime"`
|
||||
Allow_image_mime map[string]string `mapstructure:"allow_image_mime"`
|
||||
Allow_video_mime map[string]string `mapstructure:"allow_video_mime"`
|
||||
Allow_music_mime map[string]string `mapstructure:"allow_music_mime"`
|
||||
Allow_pdf_mime map[string]string `mapstructure:"allow_pdf_mime"`
|
||||
}
|
||||
|
||||
@@ -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{})
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user