初始化
This commit is contained in:
31
server/model/app.go
Normal file
31
server/model/app.go
Normal file
@@ -0,0 +1,31 @@
|
||||
package model
|
||||
|
||||
import "time"
|
||||
|
||||
// App 开放平台应用
|
||||
type App struct {
|
||||
ID uint64 `json:"id" gorm:"primaryKey;autoIncrement"`
|
||||
AppID string `json:"app_id" gorm:"uniqueIndex;size:64;not null"`
|
||||
AppSecret string `json:"-" gorm:"size:128;not null"`
|
||||
AppName string `json:"app_name" gorm:"size:128;not null"`
|
||||
Status int8 `json:"status" gorm:"default:1"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
}
|
||||
|
||||
func (App) TableName() string {
|
||||
return "fs_app"
|
||||
}
|
||||
|
||||
// AppUser 应用授权用户
|
||||
// 只有绑定的用户才能通过该应用进行SSO登录
|
||||
type AppUser struct {
|
||||
ID uint64 `json:"id" gorm:"primaryKey;autoIncrement"`
|
||||
AppID uint64 `json:"app_id" gorm:"index;not null"` // 应用ID
|
||||
UserID uint64 `json:"user_id" gorm:"index;not null"` // 用户ID
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
}
|
||||
|
||||
func (AppUser) TableName() string {
|
||||
return "fs_app_user"
|
||||
}
|
||||
46
server/model/backup.go
Normal file
46
server/model/backup.go
Normal file
@@ -0,0 +1,46 @@
|
||||
package model
|
||||
|
||||
import "time"
|
||||
|
||||
// BackupPolicy 备份策略
|
||||
type BackupPolicy struct {
|
||||
ID uint64 `json:"id" gorm:"primaryKey;autoIncrement"`
|
||||
Name string `json:"name" gorm:"size:128;not null"` // 策略名称
|
||||
BackupType string `json:"backup_type" gorm:"size:32;not null"` // full=全量, incremental=增量
|
||||
TargetType string `json:"target_type" gorm:"size:32;not null"` // local=本地, minio=MinIO
|
||||
TargetConfig string `json:"target_config" gorm:"type:json"` // 目标配置JSON
|
||||
IncludeDB int8 `json:"include_db" gorm:"default:1"` // 是否备份数据库
|
||||
IncludeFiles int8 `json:"include_files" gorm:"default:1"` // 是否备份文件
|
||||
CronExpr string `json:"cron_expr" gorm:"size:64"` // cron表达式
|
||||
MaxBackups int `json:"max_backups" gorm:"default:7"` // 最大保留数
|
||||
Status int8 `json:"status" gorm:"default:1"` // 1=启用 0=禁用
|
||||
LastRunAt *time.Time `json:"last_run_at"` // 上次执行时间
|
||||
NextRunAt *time.Time `json:"next_run_at"` // 下次执行时间
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
}
|
||||
|
||||
func (BackupPolicy) TableName() string {
|
||||
return "fs_backup_policy"
|
||||
}
|
||||
|
||||
// BackupLog 备份执行日志
|
||||
type BackupLog struct {
|
||||
ID uint64 `json:"id" gorm:"primaryKey;autoIncrement"`
|
||||
PolicyID uint64 `json:"policy_id" gorm:"index;not null"`
|
||||
PolicyName string `json:"policy_name" gorm:"size:128"`
|
||||
BackupType string `json:"backup_type" gorm:"size:32"`
|
||||
Status string `json:"status" gorm:"size:32;default:running"` // running/success/failed
|
||||
FilePath string `json:"file_path" gorm:"size:512"` // 备份文件路径
|
||||
FileSize int64 `json:"file_size"` // 备份文件大小
|
||||
DBSize int64 `json:"db_size"` // 数据库备份大小
|
||||
FilesCount int `json:"files_count"` // 备份文件数量
|
||||
Duration int `json:"duration"` // 耗时(秒)
|
||||
ErrorMsg string `json:"error_msg" gorm:"size:512"` // 错误信息
|
||||
StartedAt time.Time `json:"started_at"`
|
||||
FinishedAt *time.Time `json:"finished_at"`
|
||||
}
|
||||
|
||||
func (BackupLog) TableName() string {
|
||||
return "fs_backup_log"
|
||||
}
|
||||
22
server/model/operation_log.go
Normal file
22
server/model/operation_log.go
Normal file
@@ -0,0 +1,22 @@
|
||||
package model
|
||||
|
||||
import "time"
|
||||
|
||||
// OperationLog 操作日志
|
||||
// 记录用户的关键操作行为
|
||||
type OperationLog struct {
|
||||
ID uint64 `json:"id" gorm:"primaryKey;autoIncrement"`
|
||||
UserID uint64 `json:"user_id" gorm:"index;default:0"` // 操作人
|
||||
Username string `json:"username" gorm:"size:64"` // 操作人用户名
|
||||
Action string `json:"action" gorm:"size:32;index;not null"` // 操作类型: login/upload/download/delete/share...
|
||||
Resource string `json:"resource" gorm:"size:32;index"` // 资源类型: file/folder/user/system
|
||||
Detail string `json:"detail" gorm:"size:512"` // 操作详情
|
||||
IP string `json:"ip" gorm:"size:64"` // 客户端IP
|
||||
UserAgent string `json:"user_agent" gorm:"size:256"` // 客户端UA
|
||||
Status int `json:"status" gorm:"default:1"` // 1=成功 0=失败
|
||||
CreatedAt time.Time `json:"created_at" gorm:"index"`
|
||||
}
|
||||
|
||||
func (OperationLog) TableName() string {
|
||||
return "fs_operation_log"
|
||||
}
|
||||
29
server/model/storage_assignment.go
Normal file
29
server/model/storage_assignment.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package model
|
||||
|
||||
import "time"
|
||||
|
||||
// StorageAssignment 存储策略分配
|
||||
// 支持: 用户专属 > 角色 > 系统默认
|
||||
// 同一用户可通过多个角色获得多个存储策略, 按优先级调度
|
||||
type StorageAssignment struct {
|
||||
ID uint64 `json:"id" gorm:"primaryKey;autoIncrement"`
|
||||
PolicyID uint64 `json:"policy_id" gorm:"index;not null"` // 存储策略ID
|
||||
|
||||
// 分配目标
|
||||
UserID uint64 `json:"user_id" gorm:"index;default:0"` // 用户专属(0=不按用户)
|
||||
GroupID uint64 `json:"group_id" gorm:"index;default:0"` // 角色(0=不按角色)
|
||||
IsDefault int8 `json:"is_default" gorm:"default:0"` // 系统默认(1=是)
|
||||
|
||||
// 调度配置
|
||||
Priority int `json:"priority" gorm:"default:0"` // 优先级, 数值越大越优先
|
||||
StorageQuota int64 `json:"storage_quota" gorm:"default:0"` // 配额(字节), 0=不限
|
||||
AccessMode string `json:"access_mode" gorm:"size:32"` // 访问模式覆盖
|
||||
|
||||
Status int8 `json:"status" gorm:"default:1"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
}
|
||||
|
||||
func (StorageAssignment) TableName() string {
|
||||
return "fs_storage_assignment"
|
||||
}
|
||||
28
server/model/upload_session.go
Normal file
28
server/model/upload_session.go
Normal file
@@ -0,0 +1,28 @@
|
||||
package model
|
||||
|
||||
import "time"
|
||||
|
||||
// UploadSession 分片上传会话
|
||||
// 记录大文件分片上传的进度, 支持断点续传
|
||||
type UploadSession struct {
|
||||
ID string `json:"id" gorm:"primaryKey;size:64"` // 会话ID
|
||||
FileID uint64 `json:"file_id" gorm:"default:0"` // 上传完成后的文件ID
|
||||
FileName string `json:"file_name" gorm:"size:256;not null"` // 原始文件名
|
||||
FileSize int64 `json:"file_size" gorm:"not null"` // 文件总大小
|
||||
ChunkSize int64 `json:"chunk_size" gorm:"not null"` // 分片大小
|
||||
TotalChunks int `json:"total_chunks" gorm:"not null"` // 总分片数
|
||||
UploadedChunks string `json:"uploaded_chunks" gorm:"type:text"` // 已上传分片索引, 逗号分隔: "0,1,2"
|
||||
MD5 string `json:"md5" gorm:"size:32"` // 文件MD5
|
||||
SHA256 string `json:"sha256" gorm:"size:64"` // 文件SHA256
|
||||
FolderID uint64 `json:"folder_id" gorm:"not null"` // 目标文件夹
|
||||
OwnerID uint64 `json:"owner_id" gorm:"not null"` // 上传者
|
||||
PolicyID uint64 `json:"policy_id" gorm:"default:1"` // 存储策略ID
|
||||
Status int8 `json:"status" gorm:"default:1"` // 1=上传中 2=已完成 3=已取消
|
||||
TempDir string `json:"temp_dir" gorm:"size:512"` // 临时分片目录
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
}
|
||||
|
||||
func (UploadSession) TableName() string {
|
||||
return "fs_upload_session"
|
||||
}
|
||||
Reference in New Issue
Block a user