初始化2
This commit is contained in:
@@ -107,12 +107,14 @@ type StorageAssignRequest struct {
|
||||
|
||||
// UserStorageInfoVO 用户存储信息
|
||||
type UserStorageInfoVO struct {
|
||||
PolicyID uint64 `json:"policy_id"`
|
||||
PolicyName string `json:"policy_name"`
|
||||
PolicyType string `json:"policy_type"`
|
||||
StorageQuota int64 `json:"storage_quota"`
|
||||
UsedStorage int64 `json:"used_storage"`
|
||||
UsedPercent float64 `json:"used_percent"`
|
||||
PolicyID uint64 `json:"policy_id"`
|
||||
PolicyName string `json:"policy_name"`
|
||||
PolicyType string `json:"policy_type"`
|
||||
StorageQuota int64 `json:"storage_quota"`
|
||||
UsedStorage int64 `json:"used_storage"`
|
||||
UsedPercent float64 `json:"used_percent"`
|
||||
MaxFileSize int64 `json:"max_file_size"` // 单文件大小上限(字节)
|
||||
ChunkThreshold int64 `json:"chunk_threshold"` // 分片上传阈值(字节)
|
||||
}
|
||||
|
||||
// ========== 开放平台 ==========
|
||||
|
||||
@@ -7,6 +7,12 @@ type LoginRequest struct {
|
||||
Password string `json:"password" binding:"required"` // 密码, 必填
|
||||
}
|
||||
|
||||
// AppLoginRequest 应用登录请求(用户名+appId)
|
||||
type AppLoginRequest struct {
|
||||
Username string `json:"username" binding:"required"` // 用户名, 必填
|
||||
AppID string `json:"app_id" binding:"required"` // 开放平台应用ID, 必填
|
||||
}
|
||||
|
||||
// RegisterRequest 注册请求
|
||||
type RegisterRequest struct {
|
||||
Username string `json:"username" binding:"required,min=3,max=64"` // 用户名, 3-64字符
|
||||
|
||||
@@ -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 上传进度响应
|
||||
|
||||
26
server/dto/id_string.go
Normal file
26
server/dto/id_string.go
Normal file
@@ -0,0 +1,26 @@
|
||||
package dto
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
// StringID 自定义ID类型, JSON序列化为字符串(兼容JS大整数)
|
||||
type StringID uint64
|
||||
|
||||
func (id StringID) MarshalJSON() ([]byte, error) {
|
||||
return []byte(`"` + strconv.FormatUint(uint64(id), 10) + `"`), nil
|
||||
}
|
||||
|
||||
func (id *StringID) UnmarshalJSON(data []byte) error {
|
||||
s, err := strconv.Unquote(string(data))
|
||||
if err != nil {
|
||||
return fmt.Errorf("StringID unmarshal: %w", err)
|
||||
}
|
||||
v, err := strconv.ParseUint(s, 10, 64)
|
||||
if err != nil {
|
||||
return fmt.Errorf("StringID parse: %w", err)
|
||||
}
|
||||
*id = StringID(v)
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user