share

package
v1.10.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 22, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service 分享服务

func NewService

func NewService(repositoryManager *repository.RepositoryManager, manager *config.ConfigManager, storageService *storage.ConcreteStorageService) *Service

NewService 创建分享服务

func (*Service) CheckFileExists

func (s *Service) CheckFileExists(code string) bool

CheckFileExists 检查文件是否存在

func (*Service) CreateFileShare

func (s *Service) CreateFileShare(
	code, prefix, suffix, uuidFileName, filePath, text string,
	fileSize int64,
	expiredAt *time.Time,
	expiredCount int,
	userID *uint,
	requireAuth bool,
	ownerIP string,
) (*models.FileCode, error)

CreateFileShare 创建文件分享

func (*Service) DeleteFileShare

func (s *Service) DeleteFileShare(code string) error

DeleteFileShare 删除文件分享

func (*Service) DownloadFile

func (s *Service) DownloadFile(c *gin.Context, code string) error

DownloadFile 下载文件

func (*Service) GetFileByCode

func (s *Service) GetFileByCode(code string) (*models.FileCode, error)

GetFileByCode 通过代码获取文件

func (*Service) GetFileByCodeWithAuth

func (s *Service) GetFileByCodeWithAuth(code string, userID *uint) (*models.FileCode, error)

GetFileByCodeWithAuth 带认证获取文件 (兼容性方法)

func (*Service) GetFileInfo

func (s *Service) GetFileInfo(code string) (*models.FileCode, error)

GetFileInfo 获取文件信息(不下载)

func (*Service) GetShareStats

func (s *Service) GetShareStats(code string) (*service.ShareStatsData, error)

GetShareStats 获取分享统计信息

func (*Service) GetStorageService

func (s *Service) GetStorageService() interface{}

GetStorageService 获取存储服务 (兼容性方法)

func (*Service) IsDownloadLoginRequired added in v1.9.5

func (s *Service) IsDownloadLoginRequired() bool

func (*Service) IsUploadLoginRequired added in v1.9.5

func (s *Service) IsUploadLoginRequired() bool

func (*Service) ListUserFiles

func (s *Service) ListUserFiles(userID uint, page, pageSize int) ([]models.FileCode, int64, error)

ListUserFiles 列出用户的文件

func (*Service) RecordDownloadLog added in v1.9.5

func (s *Service) RecordDownloadLog(fileCode *models.FileCode, userID *uint, ip string, duration time.Duration)

func (*Service) RecordUploadLog added in v1.9.5

func (s *Service) RecordUploadLog(fileCode *models.FileCode, userID *uint, ip string)

func (*Service) SetUserService

func (s *Service) SetUserService(userService UserServiceInterface)

SetUserService 设置用户服务(用于避免循环依赖)

func (*Service) ShareFileWithAuth

func (s *Service) ShareFileWithAuth(req models.ShareFileRequest) (*models.ShareFileResult, error)

ShareFileWithAuth 带认证的文件分享

func (*Service) ShareText

func (s *Service) ShareText(text string, expireValue int, expireStyle string) (*models.ShareTextResult, error)

ShareText 分享文本内容

func (*Service) ShareTextWithAuth

func (s *Service) ShareTextWithAuth(text string, expireValue int, expireStyle string, userID *uint) (*models.ShareTextResult, error)

ShareTextWithAuth 带认证的文本分享 (兼容性方法)

func (*Service) UpdateFileShare

func (s *Service) UpdateFileShare(code string, updates map[string]interface{}) error

UpdateFileShare 更新文件分享信息

func (*Service) UpdateFileUsage

func (s *Service) UpdateFileUsage(code string) error

UpdateFileUsage 更新文件使用情况 (兼容性方法)

type UserServiceInterface

type UserServiceInterface interface {
	UpdateUserStats(userID uint, statsType string, value int64) error
}

UserServiceInterface 定义用户服务接口,避免循环依赖

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL