add(trunk): base interface

This commit is contained in:
pikachuim
2025-08-14 19:56:43 +08:00
parent 368dc65a6e
commit 13aad2c2fa
2 changed files with 85 additions and 0 deletions

37
layers/file/manage.go Normal file
View File

@ -0,0 +1,37 @@
package file
import (
"context"
)
// UserFileServer 文件服务接口 #################################################################
type UserFileServer interface {
// ListFile 列举文件 =======================================================================
ListFile(ctx context.Context, path []string, opt *ListFileOption) ([]*UserFileObject, error)
// FindFile 搜索文件 =======================================================================
FindFile(ctx context.Context, path []string, opt *FindFileOption) ([]*UserFileObject, error)
// Download 获取文件 =======================================================================
Download(ctx context.Context, path []string, opt *ListFileOption) ([]*LinkFileObject, error)
// Uploader 上传文件 =======================================================================
Uploader(ctx context.Context, path []string, opt *ListFileOption) ([]*BackFileAction, error)
// KillFile 删除文件 =======================================================================
KillFile(ctx context.Context, path []string, opt *KillFileOption) ([]*BackFileAction, error)
// CopyFile 复制文件 =======================================================================
CopyFile(ctx context.Context, sources []string, targets []string) ([]*BackFileAction, error)
// MoveFile 移动文件 =======================================================================
MoveFile(ctx context.Context, sources []string, targets []string) ([]*BackFileAction, error)
// MakeFile 搜索文件 =======================================================================
MakeFile(ctx context.Context, path []string, opt *MakeFileOption) ([]*BackFileAction, error)
// MakePath 搜索文件 =======================================================================
MakePath(ctx context.Context, path []string, opt *MakeFileOption) ([]*BackFileAction, error)
// FSRename 命名文件 =======================================================================
FSRename(ctx context.Context, path []string, targetName []string) ([]*BackFileAction, error)
// PermFile 设置权限 =======================================================================
PermFile(ctx context.Context, path []string, opt *PermissionFile) ([]*BackFileAction, error)
// NewShare 创建分享 =======================================================================
NewShare(ctx context.Context, path []string, opt *NewShareAction) ([]*BackFileAction, error)
// GetShare 获取分享 =======================================================================
GetShare(ctx context.Context, path []string, opt *NewShareAction) ([]*UserFileObject, error)
// DelShare 删除分享 =======================================================================
DelShare(ctx context.Context, path []string, opt *NewShareAction) ([]*BackFileAction, error)
}

48
layers/file/object.go Normal file
View File

@ -0,0 +1,48 @@
package file
import "time"
type UserFileObject struct {
showName []string // 文件名称
showPath []string // 文件路径
realName []string // 真实名称
realPath []string // 真实路径
fileSize int64 // 文件大小
fileTime time.Time // 修改时间
fileType bool // 文件类型
fileMask int16 // 文件权限
checksum int32 // 密码校验
encrypts int16 // 文件状态
}
type PermissionFile struct {
}
type LinkFileObject struct {
download []string // 下载链接
}
type ListFileOption struct {
}
type FindFileOption struct {
}
type KillFileOption struct {
}
type MakeFileOption struct {
}
type BackFileAction struct {
success bool // 是否成功
message string // 错误信息
}
type NewShareAction struct {
BackFileAction
shareID string // 分享编码
pubUrls string // 公开链接
passkey string // 分析密码
expired time.Time // 过期时间
}
type HostFileObject struct {
UserFileObject
}