初始化2

This commit is contained in:
2026-07-10 17:33:33 +08:00
parent b51ee98afa
commit 94f6ecf901
59 changed files with 3893 additions and 980 deletions

View File

@@ -4,10 +4,12 @@ import "time"
// FileVO 文件视图对象 - 返回给前端
type FileVO struct {
ID uint64 `json:"id"`
ID StringID `json:"id"`
Name string `json:"name"`
Extension string `json:"extension"`
FolderID uint64 `json:"folder_id"`
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"`
@@ -23,25 +25,33 @@ type FileVO struct {
// FolderVO 文件夹视图对象
type FolderVO struct {
ID uint64 `json:"id"`
ID StringID `json:"id"`
BizID string `json:"biz_id,omitempty"`
Name string `json:"name"`
ParentID uint64 `json:"parent_id"`
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 文件列表响应 - 包含文件和文件夹
// FileListVO 文件列表响应 - 包含文件和文件夹(分页)
type FileListVO struct {
Folders []FolderVO `json:"folders"` // 文件夹列表
Files []FileVO `json:"files"` // 文件列表
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 {
Name string `json:"name" binding:"required,max=256"` // 文件夹名称
ParentID uint64 `json:"parent_id"` // 文件夹ID, 0=根目录
BizID string `json:"biz_id"` // 业务ID(可选, 用于外部系统关联)
Name string `json:"name" binding:"required,max=256"` // 文件夹名称
ParentID StringID `json:"parent_id"` // 父文件夹ID, "0"=根目录
}
// RenameRequest 重命名请求
@@ -52,22 +62,43 @@ type RenameRequest struct {
// MoveRequest 移动请求
type MoveRequest struct {
TargetFolderID uint64 `json:"target_folder_id" binding:"required"` // 目标文件夹ID
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 uint64 `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
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 uint64 `json:"id"`
ID StringID `json:"id"`
ShareCode string `json:"share_code"`
ShareURL string `json:"share_url"`
HasPassword bool `json:"has_password"`
@@ -96,31 +127,84 @@ type ShareFileVO struct {
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 uint64 `json:"folder_id"`
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"` // 上传会话ID
Instant bool `json:"instant"` // 是否秒传
FileID uint64 `json:"file_id"` // 秒传时返回文件ID
ChunkSize int64 `json:"chunk_size"` // 分片大小
Total int `json:"total"` // 总分片数
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"`
Status string `json:"status"` // ok / exists
ETag string `json:"etag,omitempty"` // MinIO返回的ETag
Status string `json:"status"` // ok / exists
}
// ChunkUploadProgressVO 上传进度响应