feat: Enhance dependency injection and service integration
- Updated main.go to initialize email service and include it in the dependency injection container. - Refactored handlers to utilize context in service method calls, improving consistency and error handling. - Introduced new service options for upload, security, and captcha services, enhancing modularity and testability. - Removed unused repository implementations to streamline the codebase. This commit continues the effort to improve the architecture by ensuring all services are properly injected and utilized across the application.
This commit is contained in:
@@ -2,7 +2,9 @@ package service
|
||||
|
||||
import (
|
||||
"carrotskin/internal/model"
|
||||
"carrotskin/pkg/database"
|
||||
"errors"
|
||||
"time"
|
||||
)
|
||||
|
||||
// ============================================================================
|
||||
@@ -962,3 +964,17 @@ func (m *MockTokenService) GetUserIDByAccessToken(accessToken string) (int64, er
|
||||
}
|
||||
return 0, errors.New("token not found")
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// CacheManager Mock - uses database.CacheManager with nil redis
|
||||
// ============================================================================
|
||||
|
||||
// NewMockCacheManager 创建一个禁用的 CacheManager 用于测试
|
||||
// 通过设置 Enabled = false,缓存操作会被跳过,测试不依赖 Redis
|
||||
func NewMockCacheManager() *database.CacheManager {
|
||||
return database.NewCacheManager(nil, database.CacheConfig{
|
||||
Prefix: "test:",
|
||||
Expiration: 5 * time.Minute,
|
||||
Enabled: false, // 禁用缓存,测试不依赖 Redis
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user