Documentation
¶
Index ¶
- type APIKeyAuthResult
- type Service
- func (s *Service) AuthenticateAPIKey(key string) (*APIKeyAuthResult, error)
- func (s *Service) ChangePassword(userID uint, oldPassword, newPassword string) error
- func (s *Service) CheckPasswordHash(password, hash string) bool
- func (s *Service) CheckUserQuota(userID uint, fileSize int64) error
- func (s *Service) DeleteAccount(userID uint) error
- func (s *Service) DeleteUserFileByCode(userID uint, code string) error
- func (s *Service) GenerateUserAPIKey(userID uint, name string, expiresAt *time.Time) (string, *models.UserAPIKey, error)
- func (s *Service) GetAdminUserCount() (int64, error)
- func (s *Service) GetProfile(userID uint) (*models.User, error)
- func (s *Service) GetUserByID(userID uint) (*models.User, error)
- func (s *Service) GetUserFiles(userID uint, page, limit int) (interface{}, int64, error)
- func (s *Service) GetUserStats(userID uint) (*service.UserStatsData, error)
- func (s *Service) IsRegistrationAllowed() bool
- func (s *Service) IsSystemInitialized() (bool, error)
- func (s *Service) IsUserSystemEnabled() bool
- func (s *Service) ListUserAPIKeys(userID uint) ([]models.UserAPIKey, error)
- func (s *Service) Login(username, password, ipAddress, userAgent string) (string, *models.User, error)
- func (s *Service) Logout(userID uint) error
- func (s *Service) NormalizeUsername(username string) string
- func (s *Service) RecalculateAllUsersStats() error
- func (s *Service) RecalculateUserStats(userID uint) error
- func (s *Service) Register(username, email, password, nickname string) (*models.User, error)
- func (s *Service) RevokeUserAPIKey(userID, id uint) error
- func (s *Service) UpdateProfile(userID uint, updates map[string]interface{}) error
- func (s *Service) UpdateUserProfile(userID uint, nickname, avatar string) error
- func (s *Service) UpdateUserStats(userID uint, statsType string, value int64) error
- func (s *Service) ValidateToken(token string) (interface{}, error)
- func (s *Service) ValidateUserInput(username, email, password string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type APIKeyAuthResult ¶ added in v1.9.9
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service 用户服务
func NewService ¶
func NewService(repositoryManager *repository.RepositoryManager, manager *config.ConfigManager) *Service
NewService 创建用户服务
func (*Service) AuthenticateAPIKey ¶ added in v1.9.9
func (s *Service) AuthenticateAPIKey(key string) (*APIKeyAuthResult, error)
AuthenticateAPIKey 校验用户 API Key,返回认证结果
func (*Service) ChangePassword ¶
ChangePassword 修改密码
func (*Service) CheckPasswordHash ¶
CheckPasswordHash 验证密码哈希
func (*Service) CheckUserQuota ¶
CheckUserQuota 检查用户配额
func (*Service) DeleteAccount ¶
DeleteAccount 删除用户账户
func (*Service) DeleteUserFileByCode ¶
DeleteUserFileByCode 根据代码删除用户文件 (兼容性方法)
func (*Service) GenerateUserAPIKey ¶ added in v1.9.9
func (s *Service) GenerateUserAPIKey(userID uint, name string, expiresAt *time.Time) (string, *models.UserAPIKey, error)
GenerateUserAPIKey 为用户生成新的 API Key,并返回明文 Key 及记录
func (*Service) GetAdminUserCount ¶
GetAdminUserCount 获取管理员用户数量
func (*Service) GetProfile ¶
GetProfile 获取用户资料
func (*Service) GetUserByID ¶
GetUserByID 根据ID获取用户 (兼容性方法)
func (*Service) GetUserFiles ¶
GetUserFiles 获取用户文件列表 (兼容性方法)
func (*Service) GetUserStats ¶
func (s *Service) GetUserStats(userID uint) (*service.UserStatsData, error)
GetUserStats 获取用户统计信息
func (*Service) IsRegistrationAllowed ¶
IsRegistrationAllowed 检查是否允许注册 (兼容性方法)
func (*Service) IsSystemInitialized ¶
IsSystemInitialized 检测系统是否已初始化(是否有管理员用户)
func (*Service) IsUserSystemEnabled ¶
IsUserSystemEnabled 检查用户系统是否启用 - 始终返回true
func (*Service) ListUserAPIKeys ¶ added in v1.9.9
func (s *Service) ListUserAPIKeys(userID uint) ([]models.UserAPIKey, error)
ListUserAPIKeys 返回用户的全部 API Key(包含已撤销)
func (*Service) Login ¶
func (s *Service) Login(username, password, ipAddress, userAgent string) (string, *models.User, error)
Login 用户登录并返回token
func (*Service) NormalizeUsername ¶
NormalizeUsername 规范化用户名
func (*Service) RecalculateAllUsersStats ¶
RecalculateAllUsersStats 重新计算所有用户的统计数据
func (*Service) RecalculateUserStats ¶
RecalculateUserStats 重新计算用户统计数据
func (*Service) RevokeUserAPIKey ¶ added in v1.9.9
RevokeUserAPIKey 撤销指定的 API Key
func (*Service) UpdateProfile ¶
UpdateProfile 更新用户资料 - 使用结构化更新
func (*Service) UpdateUserProfile ¶
UpdateUserProfile 更新用户资料 (兼容性方法)
func (*Service) UpdateUserStats ¶
UpdateUserStats 更新用户统计信息
func (*Service) ValidateToken ¶
ValidateToken 验证令牌 (兼容性方法)
func (*Service) ValidateUserInput ¶
ValidateUserInput 验证用户输入