221 lines
8.2 KiB
Go
221 lines
8.2 KiB
Go
package dto
|
|
|
|
import "time"
|
|
|
|
// FileVO 文件视图对象 - 返回给前端
|
|
type FileVO struct {
|
|
ID StringID `json:"id"`
|
|
Name string `json:"name"`
|
|
Extension string `json:"extension"`
|
|
FolderID StringID `json:"folder_id"`
|
|
OwnerID StringID `json:"owner_id"`
|
|
OwnerName string `json:"owner_name,omitempty"`
|
|
Size int64 `json:"size"`
|
|
StorageKey string `json:"storage_key"`
|
|
StoragePolicyID uint64 `json:"storage_policy_id"`
|
|
MimeType string `json:"mime_type"`
|
|
IsFavorite int8 `json:"is_favorite"`
|
|
DownloadCount int `json:"download_count"`
|
|
Version int `json:"version"` // 乐观锁版本号
|
|
DownloadURL string `json:"download_url,omitempty"` // CDN下载链接
|
|
PreviewURL string `json:"preview_url,omitempty"` // CDN预览链接
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
}
|
|
|
|
// FolderVO 文件夹视图对象
|
|
type FolderVO struct {
|
|
ID StringID `json:"id"`
|
|
BizID string `json:"biz_id,omitempty"`
|
|
Name string `json:"name"`
|
|
ParentID StringID `json:"parent_id"`
|
|
OwnerID StringID `json:"owner_id"`
|
|
OwnerName string `json:"owner_name,omitempty"`
|
|
Path string `json:"path"`
|
|
Version int `json:"version"` // 乐观锁版本号
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
}
|
|
|
|
// FileListVO 文件列表响应 - 包含文件和文件夹(分页)
|
|
type FileListVO struct {
|
|
Folders []FolderVO `json:"folders"` // 文件夹列表(不分页)
|
|
Files []FileVO `json:"files"` // 文件列表(当前页)
|
|
TotalFiles int64 `json:"total_files"` // 文件总数
|
|
TotalFolders int64 `json:"total_folders"` // 文件夹总数
|
|
Page int `json:"page"` // 当前页码
|
|
PageSize int `json:"page_size"` // 每页大小
|
|
}
|
|
|
|
// CreateFolderRequest 创建文件夹请求
|
|
type CreateFolderRequest struct {
|
|
BizID string `json:"biz_id"` // 业务ID(可选, 用于外部系统关联)
|
|
Name string `json:"name" binding:"required,max=256"` // 文件夹名称
|
|
ParentID StringID `json:"parent_id"` // 父文件夹ID, "0"=根目录
|
|
}
|
|
|
|
// RenameRequest 重命名请求
|
|
type RenameRequest struct {
|
|
NewName string `json:"new_name" binding:"required,max=256"` // 新名称
|
|
Version int `json:"version"` // 乐观锁版本号(可选)
|
|
}
|
|
|
|
// MoveRequest 移动请求
|
|
type MoveRequest struct {
|
|
TargetFolderID StringID `json:"target_folder_id" binding:"required"` // 目标文件夹ID
|
|
}
|
|
|
|
// GrantPermissionRequest 授权文件权限请求
|
|
type GrantPermissionRequest struct {
|
|
UserID StringID `json:"user_id"` // 授权给用户(与role_id二选一)
|
|
RoleID StringID `json:"role_id"` // 授权给角色(与user_id二选一)
|
|
PermLevel string `json:"perm_level" binding:"required"` // read / write / admin
|
|
}
|
|
|
|
// FilePermissionVO 文件权限视图
|
|
type FilePermissionVO struct {
|
|
ID uint64 `json:"id"`
|
|
FileID uint64 `json:"file_id"`
|
|
UserID uint64 `json:"user_id,omitempty"`
|
|
RoleID uint64 `json:"role_id,omitempty"`
|
|
UserName string `json:"user_name,omitempty"`
|
|
RoleName string `json:"role_name,omitempty"`
|
|
PermLevel string `json:"perm_level"`
|
|
GrantBy uint64 `json:"grant_by"`
|
|
GrantByName string `json:"grant_by_name,omitempty"`
|
|
CreatedAt string `json:"created_at"`
|
|
}
|
|
|
|
// ShareCreateRequest 创建分享请求
|
|
type ShareCreateRequest struct {
|
|
FileID StringID `json:"file_id" binding:"required"`
|
|
Password string `json:"password"`
|
|
ExpireHours int `json:"expire_hours"`
|
|
MaxDownload int `json:"max_download"`
|
|
AllowPreview int `json:"allow_preview"` // 1=允许 0=禁止, 默认1
|
|
AllowDownload int `json:"allow_download"` // 1=允许 0=禁止, 默认1
|
|
}
|
|
|
|
// ShareVO 分享视图对象
|
|
type ShareVO struct {
|
|
ID StringID `json:"id"`
|
|
ShareCode string `json:"share_code"`
|
|
ShareURL string `json:"share_url"`
|
|
HasPassword bool `json:"has_password"`
|
|
ExpireAt *time.Time `json:"expire_at"`
|
|
MaxDownload int `json:"max_download"`
|
|
DownloadCount int `json:"download_count"`
|
|
AllowPreview int8 `json:"allow_preview"`
|
|
AllowDownload int8 `json:"allow_download"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
}
|
|
|
|
// ShareVerifyRequest 验证分享密码请求
|
|
type ShareVerifyRequest struct {
|
|
Password string `json:"password" binding:"required"`
|
|
}
|
|
|
|
// ShareFileVO 分享文件视图对象(公开)
|
|
type ShareFileVO struct {
|
|
Name string `json:"name"`
|
|
Extension string `json:"extension"`
|
|
Size int64 `json:"size"`
|
|
MimeType string `json:"mime_type"`
|
|
PreviewURL string `json:"preview_url"` // 预览链接
|
|
AllowPreview bool `json:"allow_preview"`
|
|
AllowDownload bool `json:"allow_download"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
}
|
|
|
|
// ========== 对外API ==========
|
|
|
|
// OpenAPIListResult 分页查询结果(树状结构)
|
|
type OpenAPIListResult struct {
|
|
FolderID uint64 `json:"folder_id"`
|
|
TotalFiles int64 `json:"total_files"`
|
|
Page int `json:"page"`
|
|
PageSize int `json:"page_size"`
|
|
Folders []OpenAPIFolderVO `json:"folders"`
|
|
Files []OpenAPIFileVO `json:"files"`
|
|
}
|
|
|
|
// OpenAPISearchResult 搜索结果(树状结构)
|
|
type OpenAPISearchResult struct {
|
|
Keyword string `json:"keyword"`
|
|
TotalFiles int64 `json:"total_files"`
|
|
Page int `json:"page"`
|
|
PageSize int `json:"page_size"`
|
|
Folders []OpenAPIFolderVO `json:"folders"`
|
|
Files []OpenAPIFileVO `json:"files"`
|
|
}
|
|
|
|
// OpenAPIFolderVO 文件夹视图(对外)
|
|
type OpenAPIFolderVO struct {
|
|
ID StringID `json:"id"`
|
|
Name string `json:"name"`
|
|
ParentID StringID `json:"parent_id"`
|
|
ChildCount int64 `json:"child_count,omitempty"`
|
|
CreatedAt string `json:"created_at"`
|
|
}
|
|
|
|
// OpenAPIFileVO 文件视图(对外)
|
|
type OpenAPIFileVO struct {
|
|
ID StringID `json:"id"`
|
|
Name string `json:"name"`
|
|
Extension string `json:"extension"`
|
|
Size int64 `json:"size"`
|
|
MD5 string `json:"md5,omitempty"`
|
|
MimeType string `json:"mime_type"`
|
|
DownloadURL string `json:"download_url"`
|
|
CreatedAt string `json:"created_at"`
|
|
}
|
|
|
|
// ========== 分片上传 ==========
|
|
|
|
// ChunkUploadInitRequest 初始化分片上传请求
|
|
type ChunkUploadInitRequest struct {
|
|
FileName string `json:"file_name" binding:"required"`
|
|
FileSize int64 `json:"file_size" binding:"required"`
|
|
MD5 string `json:"md5"` // 客户端计算的MD5(可选, 用于秒传)
|
|
FolderID StringID `json:"folder_id"`
|
|
PolicyID uint64 `json:"policy_id"` // 存储策略ID
|
|
}
|
|
|
|
// ChunkUploadInitVO 初始化分片上传响应
|
|
type ChunkUploadInitVO struct {
|
|
UploadID string `json:"upload_id"`
|
|
Instant bool `json:"instant"`
|
|
FileID uint64 `json:"file_id"`
|
|
ChunkSize int64 `json:"chunk_size"`
|
|
Total int `json:"total"`
|
|
Mode string `json:"mode"` // local=服务端中转, minio=客户端直传
|
|
UploadURL string `json:"upload_url"` // MinIO模式: 分片上传基础URL
|
|
Parts []ChunkPresignURL `json:"parts,omitempty"` // MinIO模式: 各分片预签名URL
|
|
}
|
|
|
|
// ChunkPresignURL 分片预签名URL
|
|
type ChunkPresignURL struct {
|
|
Index int `json:"index"`
|
|
URL string `json:"url"`
|
|
}
|
|
|
|
// ChunkUploadChunkVO 单分片上传响应
|
|
type ChunkUploadChunkVO struct {
|
|
Index int `json:"index"`
|
|
Size int64 `json:"size"`
|
|
ETag string `json:"etag,omitempty"` // MinIO返回的ETag
|
|
Status string `json:"status"` // ok / exists
|
|
}
|
|
|
|
// ChunkUploadProgressVO 上传进度响应
|
|
type ChunkUploadProgressVO struct {
|
|
UploadID string `json:"upload_id"`
|
|
FileName string `json:"file_name"`
|
|
FileSize int64 `json:"file_size"`
|
|
ChunkSize int64 `json:"chunk_size"`
|
|
TotalChunks int `json:"total_chunks"`
|
|
Uploaded int `json:"uploaded"`
|
|
Missing []int `json:"missing"` // 未上传的分片索引
|
|
Status int8 `json:"status"` // 1=上传中 2=已完成 3=已取消
|
|
}
|