Documentation
¶
Index ¶
- type AdminOperationLogDAO
- type ChunkDAO
- func (dao *ChunkDAO) CountCompletedChunks(uploadID string) (int64, error)
- func (dao *ChunkDAO) Create(chunk *db.UploadChunk) error
- func (dao *ChunkDAO) DeleteByUploadID(uploadID string) error
- func (dao *ChunkDAO) DeleteChunksByUploadIDs(uploadIDs []string) (int, error)
- func (dao *ChunkDAO) FirstOrCreateChunk(chunk *db.UploadChunk) error
- func (dao *ChunkDAO) GetByHash(chunkHash string, fileSize int64) (*db.UploadChunk, error)
- func (dao *ChunkDAO) GetByUploadID(uploadID string) (*db.UploadChunk, error)
- func (dao *ChunkDAO) GetChunkByIndex(uploadID string, chunkIndex int) (*db.UploadChunk, error)
- func (dao *ChunkDAO) GetIncompleteUploads(olderThan int) ([]db.UploadChunk, error)
- func (dao *ChunkDAO) GetOldChunks(cutoffTime time.Time) ([]db.UploadChunk, error)
- func (dao *ChunkDAO) GetUploadList(page, pageSize int) ([]db.UploadChunk, int64, error)
- func (dao *ChunkDAO) GetUploadedChunkIndexes(uploadID string) ([]int, error)
- func (dao *ChunkDAO) UpdateChunkCompleted(uploadID string, chunkIndex int, chunkHash string) error
- func (dao *ChunkDAO) UpdateUploadProgress(uploadID string, completedChunks int) error
- type FileCodeDAO
- func (dao *FileCodeDAO) CheckCodeExists(code string, excludeID uint) (bool, error)
- func (dao *FileCodeDAO) Count() (int64, error)
- func (dao *FileCodeDAO) CountActive() (int64, error)
- func (dao *FileCodeDAO) CountByUserID(userID uint) (int64, error)
- func (dao *FileCodeDAO) CountToday() (int64, error)
- func (dao *FileCodeDAO) CountTodayUploads() (int64, error)
- func (dao *FileCodeDAO) Create(fileCode *models.FileCode) error
- func (dao *FileCodeDAO) Delete(id uint) error
- func (dao *FileCodeDAO) DeleteByFileCode(fileCode *models.FileCode) error
- func (dao *FileCodeDAO) DeleteByUserID(tx *gorm.DB, userID uint) error
- func (dao *FileCodeDAO) DeleteExpiredFiles(expiredFiles []models.FileCode) (int, error)
- func (dao *FileCodeDAO) GetByCode(code string) (*models.FileCode, error)
- func (dao *FileCodeDAO) GetByHash(fileHash string, fileSize int64) (*models.FileCode, error)
- func (dao *FileCodeDAO) GetByHashAndSize(fileHash string, size int64) (*models.FileCode, error)
- func (dao *FileCodeDAO) GetByID(id uint) (*models.FileCode, error)
- func (dao *FileCodeDAO) GetByUserID(userID uint, fileID uint) (*models.FileCode, error)
- func (dao *FileCodeDAO) GetExpiredFiles() ([]models.FileCode, error)
- func (dao *FileCodeDAO) GetFilesByUserID(userID uint) ([]models.FileCode, error)
- func (dao *FileCodeDAO) GetFilesByUserIDWithPagination(userID uint, page, pageSize int) ([]models.FileCode, int64, error)
- func (dao *FileCodeDAO) GetTotalSize() (int64, error)
- func (dao *FileCodeDAO) GetTotalSizeByUserID(userID uint) (int64, error)
- func (dao *FileCodeDAO) List(page, pageSize int, search string) ([]models.FileCode, int64, error)
- func (dao *FileCodeDAO) Update(fileCode *models.FileCode) error
- func (dao *FileCodeDAO) UpdateColumns(id uint, updates map[string]interface{}) error
- type RepositoryManager
- type TransferLogDAO
- type UserAPIKeyDAO
- func (dao *UserAPIKeyDAO) CountActiveByUser(userID uint) (int64, error)
- func (dao *UserAPIKeyDAO) Create(key *models.UserAPIKey) error
- func (dao *UserAPIKeyDAO) GetActiveByHash(hash string) (*models.UserAPIKey, error)
- func (dao *UserAPIKeyDAO) ListByUser(userID uint) ([]models.UserAPIKey, error)
- func (dao *UserAPIKeyDAO) RevokeByID(userID, id uint) error
- func (dao *UserAPIKeyDAO) TouchLastUsed(id uint) error
- type UserDAO
- func (dao *UserDAO) CheckEmailExists(email string, excludeID uint) (*models.User, error)
- func (dao *UserDAO) CheckExists(username, email string) (*models.User, error)
- func (dao *UserDAO) Count() (int64, error)
- func (dao *UserDAO) CountActive() (int64, error)
- func (dao *UserDAO) CountAdminUsers() (int64, error)
- func (dao *UserDAO) CountTodayRegistrations() (int64, error)
- func (dao *UserDAO) Create(user *models.User) error
- func (dao *UserDAO) Delete(tx *gorm.DB, user *models.User) error
- func (dao *UserDAO) GetAllUsers(page, pageSize int) ([]models.User, int64, error)
- func (dao *UserDAO) GetByEmail(email string) (*models.User, error)
- func (dao *UserDAO) GetByID(id uint) (*models.User, error)
- func (dao *UserDAO) GetByUsername(username string) (*models.User, error)
- func (dao *UserDAO) GetByUsernameOrEmail(usernameOrEmail string) (*models.User, error)
- func (dao *UserDAO) List(page, pageSize int, search string) ([]models.User, int64, error)
- func (dao *UserDAO) Update(user *models.User) error
- func (dao *UserDAO) UpdateColumns(id uint, updates map[string]interface{}) error
- func (dao *UserDAO) UpdatePassword(id uint, passwordHash string) error
- func (dao *UserDAO) UpdateStatus(id uint, status string) error
- func (dao *UserDAO) UpdateUserFields(id uint, user models.User) error
- func (dao *UserDAO) UpdateUserProfile(id uint, user *models.User) error
- type UserSessionDAO
- func (dao *UserSessionDAO) CleanExpiredSessions() error
- func (dao *UserSessionDAO) CountActiveSessionsByUserID(userID uint) (int64, error)
- func (dao *UserSessionDAO) Create(session *models.UserSession) error
- func (dao *UserSessionDAO) DeactivateUserSessions(userID uint) error
- func (dao *UserSessionDAO) DeleteByUserID(tx *gorm.DB, userID uint) error
- func (dao *UserSessionDAO) GetBySessionID(sessionID string) (*models.UserSession, error)
- func (dao *UserSessionDAO) GetOldestSessionByUserID(userID uint) (*models.UserSession, error)
- func (dao *UserSessionDAO) GetUserSessions(userID uint, page, pageSize int) ([]models.UserSession, int64, error)
- func (dao *UserSessionDAO) UpdateIsActive(session *models.UserSession, isActive bool) error
- func (dao *UserSessionDAO) UpdateIsActiveByID(id uint, isActive bool) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AdminOperationLogDAO ¶ added in v1.9.5
type AdminOperationLogDAO struct {
// contains filtered or unexported fields
}
AdminOperationLogDAO 管理后台运维日志
func NewAdminOperationLogDAO ¶ added in v1.9.5
func NewAdminOperationLogDAO(db *gorm.DB) *AdminOperationLogDAO
func (*AdminOperationLogDAO) Create ¶ added in v1.9.5
func (dao *AdminOperationLogDAO) Create(log *models.AdminOperationLog) error
func (*AdminOperationLogDAO) List ¶ added in v1.9.5
func (dao *AdminOperationLogDAO) List(query db.AdminOperationLogQuery) ([]models.AdminOperationLog, int64, error)
type ChunkDAO ¶
type ChunkDAO struct {
// contains filtered or unexported fields
}
ChunkDAO 分片上传数据访问对象
func (*ChunkDAO) CountCompletedChunks ¶
CountCompletedChunks 统计已完成的分片数量
func (*ChunkDAO) DeleteByUploadID ¶
DeleteByUploadID 删除上传相关的所有分片记录
func (*ChunkDAO) DeleteChunksByUploadIDs ¶
DeleteChunksByUploadIDs 批量删除指定上传ID的所有分片记录
func (*ChunkDAO) FirstOrCreateChunk ¶
func (dao *ChunkDAO) FirstOrCreateChunk(chunk *db.UploadChunk) error
FirstOrCreateChunk 创建或更新分片记录
func (*ChunkDAO) GetByUploadID ¶
func (dao *ChunkDAO) GetByUploadID(uploadID string) (*db.UploadChunk, error)
GetByUploadID 根据上传ID获取控制记录
func (*ChunkDAO) GetChunkByIndex ¶
GetChunkByIndex 根据上传ID和分片索引获取分片
func (*ChunkDAO) GetIncompleteUploads ¶
func (dao *ChunkDAO) GetIncompleteUploads(olderThan int) ([]db.UploadChunk, error)
GetIncompleteUploads 获取未完成的上传(用于清理)
func (*ChunkDAO) GetOldChunks ¶
GetOldChunks 获取超过指定时间的未完成分片上传
func (*ChunkDAO) GetUploadList ¶
GetUploadList 获取上传列表(用于管理和清理)
func (*ChunkDAO) GetUploadedChunkIndexes ¶
GetUploadedChunkIndexes 获取已上传分片的索引列表
func (*ChunkDAO) UpdateChunkCompleted ¶
UpdateChunkCompleted 更新分片完成状态
type FileCodeDAO ¶
type FileCodeDAO struct {
// contains filtered or unexported fields
}
FileCodeDAO 文件代码数据访问对象
func (*FileCodeDAO) CheckCodeExists ¶
func (dao *FileCodeDAO) CheckCodeExists(code string, excludeID uint) (bool, error)
CheckCodeExists 检查代码是否存在(排除指定ID)
func (*FileCodeDAO) CountActive ¶
func (dao *FileCodeDAO) CountActive() (int64, error)
CountActive 统计活跃文件数量
func (*FileCodeDAO) CountByUserID ¶
func (dao *FileCodeDAO) CountByUserID(userID uint) (int64, error)
CountByUserID 统计用户上传的文件数量
func (*FileCodeDAO) CountToday ¶
func (dao *FileCodeDAO) CountToday() (int64, error)
CountToday 统计今天的文件数量
func (*FileCodeDAO) CountTodayUploads ¶
func (dao *FileCodeDAO) CountTodayUploads() (int64, error)
CountTodayUploads 统计今天的上传数量
func (*FileCodeDAO) Create ¶
func (dao *FileCodeDAO) Create(fileCode *models.FileCode) error
Create 创建新的文件记录
func (*FileCodeDAO) DeleteByFileCode ¶
func (dao *FileCodeDAO) DeleteByFileCode(fileCode *models.FileCode) error
DeleteByFileCode 删除文件记录
func (*FileCodeDAO) DeleteByUserID ¶
func (dao *FileCodeDAO) DeleteByUserID(tx *gorm.DB, userID uint) error
DeleteByUserID 删除用户的所有文件
func (*FileCodeDAO) DeleteExpiredFiles ¶
func (dao *FileCodeDAO) DeleteExpiredFiles(expiredFiles []models.FileCode) (int, error)
DeleteExpiredFiles 批量删除过期文件
func (*FileCodeDAO) GetByCode ¶
func (dao *FileCodeDAO) GetByCode(code string) (*models.FileCode, error)
GetByCode 根据代码获取文件记录
func (*FileCodeDAO) GetByHashAndSize ¶
GetByHashAndSize 根据文件哈希和大小获取文件记录
func (*FileCodeDAO) GetByID ¶
func (dao *FileCodeDAO) GetByID(id uint) (*models.FileCode, error)
GetByID 根据ID获取文件记录
func (*FileCodeDAO) GetByUserID ¶
GetByUserID 获取用户的文件记录
func (*FileCodeDAO) GetExpiredFiles ¶
func (dao *FileCodeDAO) GetExpiredFiles() ([]models.FileCode, error)
GetExpiredFiles 获取过期文件
func (*FileCodeDAO) GetFilesByUserID ¶
func (dao *FileCodeDAO) GetFilesByUserID(userID uint) ([]models.FileCode, error)
GetFilesByUserID 获取用户的所有文件
func (*FileCodeDAO) GetFilesByUserIDWithPagination ¶
func (dao *FileCodeDAO) GetFilesByUserIDWithPagination(userID uint, page, pageSize int) ([]models.FileCode, int64, error)
GetFilesByUserIDWithPagination 获取用户的文件列表(带分页)
func (*FileCodeDAO) GetTotalSize ¶
func (dao *FileCodeDAO) GetTotalSize() (int64, error)
GetTotalSize 获取文件总大小
func (*FileCodeDAO) GetTotalSizeByUserID ¶
func (dao *FileCodeDAO) GetTotalSizeByUserID(userID uint) (int64, error)
GetTotalSizeByUserID 获取用户文件总大小
func (*FileCodeDAO) Update ¶
func (dao *FileCodeDAO) Update(fileCode *models.FileCode) error
Update 更新文件记录
func (*FileCodeDAO) UpdateColumns ¶
func (dao *FileCodeDAO) UpdateColumns(id uint, updates map[string]interface{}) error
UpdateColumns 更新指定字段
type RepositoryManager ¶
type RepositoryManager struct {
User *UserDAO
FileCode *FileCodeDAO
Chunk *ChunkDAO
UserSession *UserSessionDAO
Upload *ChunkDAO
TransferLog *TransferLogDAO
AdminOpLog *AdminOperationLogDAO
UserAPIKey *UserAPIKeyDAO
// contains filtered or unexported fields
}
RepositoryManager 数据访问管理器
func NewRepositoryManager ¶
func NewRepositoryManager(db *gorm.DB) *RepositoryManager
NewRepositoryManager 创建新的数据访问管理器
func (*RepositoryManager) BeginTransaction ¶
func (m *RepositoryManager) BeginTransaction() *gorm.DB
BeginTransaction 开始事务
func (*RepositoryManager) DB ¶ added in v1.7.1
func (m *RepositoryManager) DB() *gorm.DB
DB 返回底层 gorm.DB 引用(只读)
type TransferLogDAO ¶ added in v1.9.5
type TransferLogDAO struct {
// contains filtered or unexported fields
}
func NewTransferLogDAO ¶ added in v1.9.5
func NewTransferLogDAO(db *gorm.DB) *TransferLogDAO
func (*TransferLogDAO) Create ¶ added in v1.9.5
func (dao *TransferLogDAO) Create(log *models.TransferLog) error
func (*TransferLogDAO) List ¶ added in v1.9.5
func (dao *TransferLogDAO) List(query db.TransferLogQuery) ([]models.TransferLog, int64, error)
List 返回传输日志,支持基本筛选和分页
func (*TransferLogDAO) WithDB ¶ added in v1.9.5
func (dao *TransferLogDAO) WithDB(db *gorm.DB) *TransferLogDAO
type UserAPIKeyDAO ¶ added in v1.9.9
type UserAPIKeyDAO struct {
// contains filtered or unexported fields
}
func NewUserAPIKeyDAO ¶ added in v1.9.9
func NewUserAPIKeyDAO(db *gorm.DB) *UserAPIKeyDAO
NewUserAPIKeyDAO 创建 DAO
func (*UserAPIKeyDAO) CountActiveByUser ¶ added in v1.9.9
func (dao *UserAPIKeyDAO) CountActiveByUser(userID uint) (int64, error)
CountActiveByUser 统计用户有效密钥数量
func (*UserAPIKeyDAO) Create ¶ added in v1.9.9
func (dao *UserAPIKeyDAO) Create(key *models.UserAPIKey) error
Create 创建新的 API Key 记录
func (*UserAPIKeyDAO) GetActiveByHash ¶ added in v1.9.9
func (dao *UserAPIKeyDAO) GetActiveByHash(hash string) (*models.UserAPIKey, error)
GetActiveByHash 根据哈希获取有效密钥(未撤销且未过期)
func (*UserAPIKeyDAO) ListByUser ¶ added in v1.9.9
func (dao *UserAPIKeyDAO) ListByUser(userID uint) ([]models.UserAPIKey, error)
ListByUser 返回某个用户的所有密钥(包含已撤销),按创建时间倒序
func (*UserAPIKeyDAO) RevokeByID ¶ added in v1.9.9
func (dao *UserAPIKeyDAO) RevokeByID(userID, id uint) error
RevokeByID 撤销密钥
func (*UserAPIKeyDAO) TouchLastUsed ¶ added in v1.9.9
func (dao *UserAPIKeyDAO) TouchLastUsed(id uint) error
TouchLastUsed 更新最后使用时间
type UserDAO ¶
type UserDAO struct {
// contains filtered or unexported fields
}
UserDAO 用户数据访问对象
func (*UserDAO) CheckEmailExists ¶
CheckEmailExists 检查邮箱是否存在(排除指定ID)
func (*UserDAO) CheckExists ¶
CheckExists 检查用户是否存在(用户名或邮箱)
func (*UserDAO) CountAdminUsers ¶
CountAdminUsers 统计管理员用户数量
func (*UserDAO) CountTodayRegistrations ¶
CountTodayRegistrations 统计今天注册的用户数
func (*UserDAO) GetAllUsers ¶
GetAllUsers 获取所有用户(管理员用途)
func (*UserDAO) GetByEmail ¶
GetByEmail 根据邮箱获取用户
func (*UserDAO) GetByUsername ¶
GetByUsername 根据用户名获取用户
func (*UserDAO) GetByUsernameOrEmail ¶
GetByUsernameOrEmail 根据用户名或邮箱获取用户
func (*UserDAO) UpdateColumns ¶
UpdateColumns 更新指定字段
func (*UserDAO) UpdatePassword ¶
UpdatePassword 更新用户密码
func (*UserDAO) UpdateStatus ¶
UpdateStatus 更新用户状态
func (*UserDAO) UpdateUserFields ¶
UpdateUserFields 更新用户字段(结构化方式)
type UserSessionDAO ¶
type UserSessionDAO struct {
// contains filtered or unexported fields
}
UserSessionDAO 用户会话数据访问对象
func NewUserSessionDAO ¶
func NewUserSessionDAO(db *gorm.DB) *UserSessionDAO
NewUserSessionDAO 创建新的用户会话DAO
func (*UserSessionDAO) CleanExpiredSessions ¶
func (dao *UserSessionDAO) CleanExpiredSessions() error
CleanExpiredSessions 清理过期会话
func (*UserSessionDAO) CountActiveSessionsByUserID ¶
func (dao *UserSessionDAO) CountActiveSessionsByUserID(userID uint) (int64, error)
CountActiveSessionsByUserID 统计用户的活跃会话数
func (*UserSessionDAO) Create ¶
func (dao *UserSessionDAO) Create(session *models.UserSession) error
Create 创建新会话
func (*UserSessionDAO) DeactivateUserSessions ¶
func (dao *UserSessionDAO) DeactivateUserSessions(userID uint) error
DeactivateUserSessions 停用用户的所有会话
func (*UserSessionDAO) DeleteByUserID ¶
func (dao *UserSessionDAO) DeleteByUserID(tx *gorm.DB, userID uint) error
DeleteByUserID 删除用户的所有会话
func (*UserSessionDAO) GetBySessionID ¶
func (dao *UserSessionDAO) GetBySessionID(sessionID string) (*models.UserSession, error)
GetBySessionID 根据会话ID获取会话
func (*UserSessionDAO) GetOldestSessionByUserID ¶
func (dao *UserSessionDAO) GetOldestSessionByUserID(userID uint) (*models.UserSession, error)
GetOldestSessionByUserID 获取用户最老的会话
func (*UserSessionDAO) GetUserSessions ¶
func (dao *UserSessionDAO) GetUserSessions(userID uint, page, pageSize int) ([]models.UserSession, int64, error)
GetUserSessions 获取用户的会话列表
func (*UserSessionDAO) UpdateIsActive ¶
func (dao *UserSessionDAO) UpdateIsActive(session *models.UserSession, isActive bool) error
UpdateIsActive 更新会话活跃状态
func (*UserSessionDAO) UpdateIsActiveByID ¶
func (dao *UserSessionDAO) UpdateIsActiveByID(id uint, isActive bool) error
UpdateIsActiveByID 根据ID更新会话活跃状态