- files 表:相对路径、MIME、扩展名、大小、sha256 唯一(秒传)、引用计数、上传者、存储后端、元数据等 - file_operations 表:create/download/rename/move/delete 五种操作,含文件快照、操作人快照与 IP - 迁移 v8、v9;补充 hash 唯一约束与操作日志读写测试
30 lines
1.1 KiB
Go
30 lines
1.1 KiB
Go
package model
|
|
|
|
import "time"
|
|
|
|
// 文件操作类型。
|
|
const (
|
|
FileOperationCreate = "create"
|
|
FileOperationDelete = "delete"
|
|
FileOperationMove = "move"
|
|
FileOperationRename = "rename"
|
|
FileOperationDownload = "download"
|
|
)
|
|
|
|
// FileOperation 文件操作日志,追加型记录;无外键,文件物理删除后日志仍保留。
|
|
type FileOperation struct {
|
|
ID uint `gorm:"primaryKey" json:"id"`
|
|
FileID uint `gorm:"index;not null" json:"file_id"`
|
|
FileName string `gorm:"size:255" json:"file_name"`
|
|
FileHash string `gorm:"size:64" json:"file_hash"`
|
|
Operation string `gorm:"size:20;not null" json:"operation"`
|
|
OperatorID *uint `gorm:"index" json:"operator_id"`
|
|
Operator string `gorm:"size:50" json:"operator"`
|
|
PathBefore string `gorm:"size:512" json:"path_before"`
|
|
PathAfter string `gorm:"size:512" json:"path_after"`
|
|
NameBefore string `gorm:"size:255" json:"name_before"`
|
|
NameAfter string `gorm:"size:255" json:"name_after"`
|
|
IP string `gorm:"size:45" json:"ip"`
|
|
CreatedAt time.Time `gorm:"index" json:"created_at"`
|
|
}
|