初始化
This commit is contained in:
59
server/model/file.go
Normal file
59
server/model/file.go
Normal file
@@ -0,0 +1,59 @@
|
||||
package model
|
||||
|
||||
import "time"
|
||||
|
||||
// File 文件模型
|
||||
type File struct {
|
||||
ID uint64 `json:"id" gorm:"primaryKey;autoIncrement"`
|
||||
Name string `json:"name" gorm:"size:256;not null"`
|
||||
Extension string `json:"extension" gorm:"size:32"`
|
||||
FolderID uint64 `json:"folder_id" gorm:"index;not null"`
|
||||
OwnerID uint64 `json:"owner_id" gorm:"index;not null"`
|
||||
Size int64 `json:"size" gorm:"default:0"`
|
||||
MD5 string `json:"md5" gorm:"size:32;index"`
|
||||
SHA256 string `json:"sha256" gorm:"size:64"`
|
||||
StorageKey string `json:"storage_key" gorm:"size:512;not null"`
|
||||
StoragePolicyID uint64 `json:"storage_policy_id" gorm:"index;default:1"`
|
||||
MimeType string `json:"mime_type" gorm:"size:128"`
|
||||
IsFavorite int8 `json:"is_favorite" gorm:"default:0"`
|
||||
Status int8 `json:"status" gorm:"default:1"`
|
||||
DownloadCount int `json:"download_count" gorm:"default:0"`
|
||||
Version int `json:"version" gorm:"default:1"` // 乐观锁版本号
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
}
|
||||
|
||||
// TableName 指定表名
|
||||
func (File) TableName() string {
|
||||
return "fs_file"
|
||||
}
|
||||
|
||||
// FileAssociation 业务文件关联模型
|
||||
// 用于兼容 OA 系统的文件关联
|
||||
type FileAssociation struct {
|
||||
ID uint64 `json:"id" gorm:"primaryKey;autoIncrement"`
|
||||
BizID string `json:"biz_id" gorm:"size:128;index;not null"`
|
||||
BizType string `json:"biz_type" gorm:"size:64;index;not null"`
|
||||
FileID uint64 `json:"file_id" gorm:"not null"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
}
|
||||
|
||||
// TableName 指定表名
|
||||
func (FileAssociation) TableName() string {
|
||||
return "fs_file_association"
|
||||
}
|
||||
|
||||
// FilePermission 文件权限模型
|
||||
type FilePermission struct {
|
||||
ID uint64 `json:"id" gorm:"primaryKey;autoIncrement"`
|
||||
FileID uint64 `json:"file_id" gorm:"not null"`
|
||||
UserID uint64 `json:"user_id" gorm:"default:0"`
|
||||
RoleID uint64 `json:"role_id" gorm:"default:0"`
|
||||
PermLevel string `json:"perm_level" gorm:"size:16;default:read"`
|
||||
GrantBy uint64 `json:"grant_by" gorm:"not null"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
}
|
||||
|
||||
func (FilePermission) TableName() string {
|
||||
return "fs_file_permission"
|
||||
}
|
||||
Reference in New Issue
Block a user