feat: 新增路由配置,负责初始化所有仓库、服务和处理器并设置认证。
This commit is contained in:
@@ -52,15 +52,18 @@ func Setup(db *gorm.DB, yunAPIClient *service.YunAPIClient, cfg *config.Config)
|
|||||||
notificationRepo := repository.NewNotificationRepository(db)
|
notificationRepo := repository.NewNotificationRepository(db)
|
||||||
streakRepo := repository.NewStreakRepository(db)
|
streakRepo := repository.NewStreakRepository(db)
|
||||||
|
|
||||||
|
// Initialize services (Stage 1: Core Services needed for Auth)
|
||||||
|
ledgerService := service.NewLedgerService(ledgerRepo, db)
|
||||||
|
|
||||||
// Initialize auth services
|
// Initialize auth services
|
||||||
authService := service.NewAuthService(userRepo, cfg)
|
authService := service.NewAuthService(userRepo, ledgerService, cfg)
|
||||||
var gitHubOAuthService *service.GitHubOAuthService
|
var gitHubOAuthService *service.GitHubOAuthService
|
||||||
if cfg.GitHubClientID != "" && cfg.GitHubClientSecret != "" {
|
if cfg.GitHubClientID != "" && cfg.GitHubClientSecret != "" {
|
||||||
gitHubOAuthService = service.NewGitHubOAuthService(userRepo, authService, cfg)
|
gitHubOAuthService = service.NewGitHubOAuthService(userRepo, authService, ledgerService, cfg)
|
||||||
}
|
}
|
||||||
var giteeOAuthService *service.GiteeOAuthService
|
var giteeOAuthService *service.GiteeOAuthService
|
||||||
if cfg.GiteeClientID != "" && cfg.GiteeClientSecret != "" {
|
if cfg.GiteeClientID != "" && cfg.GiteeClientSecret != "" {
|
||||||
giteeOAuthService = service.NewGiteeOAuthService(userRepo, authService, cfg)
|
giteeOAuthService = service.NewGiteeOAuthService(userRepo, authService, ledgerService, cfg)
|
||||||
}
|
}
|
||||||
authHandler := handler.NewAuthHandlerWithConfig(authService, gitHubOAuthService, giteeOAuthService, cfg)
|
authHandler := handler.NewAuthHandlerWithConfig(authService, gitHubOAuthService, giteeOAuthService, cfg)
|
||||||
authMiddleware := middleware.NewAuthMiddleware(authService)
|
authMiddleware := middleware.NewAuthMiddleware(authService)
|
||||||
@@ -85,7 +88,7 @@ func Setup(db *gorm.DB, yunAPIClient *service.YunAPIClient, cfg *config.Config)
|
|||||||
repaymentService := service.NewRepaymentService(repaymentRepo, billingRepo, accountRepo, db)
|
repaymentService := service.NewRepaymentService(repaymentRepo, billingRepo, accountRepo, db)
|
||||||
backupService := service.NewBackupService(db)
|
backupService := service.NewBackupService(db)
|
||||||
appLockService := service.NewAppLockService(appLockRepo)
|
appLockService := service.NewAppLockService(appLockRepo)
|
||||||
ledgerService := service.NewLedgerService(ledgerRepo, db)
|
// ledgerService initialized earlier
|
||||||
reimbursementService := service.NewReimbursementService(db, transactionRepo, accountRepo)
|
reimbursementService := service.NewReimbursementService(db, transactionRepo, accountRepo)
|
||||||
refundService := service.NewRefundService(db, transactionRepo, accountRepo)
|
refundService := service.NewRefundService(db, transactionRepo, accountRepo)
|
||||||
userSettingsService := service.NewUserSettingsService(userSettingsRepo)
|
userSettingsService := service.NewUserSettingsService(userSettingsRepo)
|
||||||
|
|||||||
Reference in New Issue
Block a user