feat: 新增路由配置、交易处理和用户连击功能,并初始化相关服务与处理器

This commit is contained in:
2026-01-28 10:08:48 +08:00
parent 4d024eba8e
commit e811256d99
7 changed files with 508 additions and 2 deletions

View File

@@ -50,6 +50,7 @@ func Setup(db *gorm.DB, yunAPIClient *service.YunAPIClient, cfg *config.Config)
userSettingsRepo := repository.NewUserSettingsRepository(db)
userRepo := repository.NewUserRepository(db)
notificationRepo := repository.NewNotificationRepository(db)
streakRepo := repository.NewStreakRepository(db)
// Initialize auth services
authService := service.NewAuthService(userRepo, cfg)
@@ -85,6 +86,7 @@ func Setup(db *gorm.DB, yunAPIClient *service.YunAPIClient, cfg *config.Config)
refundService := service.NewRefundService(db, transactionRepo, accountRepo)
userSettingsService := service.NewUserSettingsService(userSettingsRepo)
notificationService := service.NewNotificationService(notificationRepo)
streakService := service.NewStreakService(streakRepo)
// Feature: financial-core-upgrade - Initialize new services
subAccountService := service.NewSubAccountService(accountRepo, db)
@@ -100,7 +102,8 @@ func Setup(db *gorm.DB, yunAPIClient *service.YunAPIClient, cfg *config.Config)
categoryHandler := handler.NewCategoryHandler(categoryService)
tagHandler := handler.NewTagHandler(tagService)
classificationHandler := handler.NewClassificationHandler(classificationService)
transactionHandler := handler.NewTransactionHandler(transactionService)
transactionHandler := handler.NewTransactionHandlerWithStreak(transactionService, streakService)
imageHandler := handler.NewImageHandler(imageService)
recurringHandler := handler.NewRecurringTransactionHandler(recurringService)
exchangeRateHandler := handler.NewExchangeRateHandlerWithClient(exchangeRateService, yunAPIClient)
@@ -128,6 +131,9 @@ func Setup(db *gorm.DB, yunAPIClient *service.YunAPIClient, cfg *config.Config)
// Feature: health-score - Initialize health score handler
healthScoreHandler := handler.NewHealthScoreHandler(healthScoreService)
// Feature: streak - Initialize streak handler
streakHandler := handler.NewStreakHandler(streakService)
// AI Bookkeeping Service and Handler
aiBookkeepingService := service.NewAIBookkeepingService(
cfg,
@@ -253,6 +259,9 @@ func Setup(db *gorm.DB, yunAPIClient *service.YunAPIClient, cfg *config.Config)
// Register health score routes
healthScoreHandler.RegisterRoutes(protected)
// Feature: streak - Register streak routes
streakHandler.RegisterRoutes(protected)
}
}
@@ -314,6 +323,7 @@ func SetupWithRedis(db *gorm.DB, yunAPIClient *service.YunAPIClient, redisClient
userSettingsRepo := repository.NewUserSettingsRepository(db)
userRepo := repository.NewUserRepository(db)
notificationRepo := repository.NewNotificationRepository(db)
streakRepo := repository.NewStreakRepository(db)
// Initialize auth services
authService := service.NewAuthService(userRepo, cfg)
@@ -348,6 +358,7 @@ func SetupWithRedis(db *gorm.DB, yunAPIClient *service.YunAPIClient, redisClient
refundService := service.NewRefundService(db, transactionRepo, accountRepo)
userSettingsService := service.NewUserSettingsService(userSettingsRepo)
notificationService := service.NewNotificationService(notificationRepo)
streakService := service.NewStreakService(streakRepo)
// Feature: financial-core-upgrade - Initialize new services
subAccountService := service.NewSubAccountService(accountRepo, db)
@@ -367,7 +378,7 @@ func SetupWithRedis(db *gorm.DB, yunAPIClient *service.YunAPIClient, redisClient
categoryHandler := handler.NewCategoryHandler(categoryService)
tagHandler := handler.NewTagHandler(tagService)
classificationHandler := handler.NewClassificationHandler(classificationService)
transactionHandler := handler.NewTransactionHandler(transactionService)
transactionHandler := handler.NewTransactionHandlerWithStreak(transactionService, streakService)
imageHandler := handler.NewImageHandler(imageService)
recurringHandler := handler.NewRecurringTransactionHandler(recurringService)
reportHandler := handler.NewReportHandler(reportService, pdfExportService, excelExportService)
@@ -391,6 +402,9 @@ func SetupWithRedis(db *gorm.DB, yunAPIClient *service.YunAPIClient, redisClient
defaultAccountHandler := handler.NewDefaultAccountHandler(userSettingsServiceWithAccounts)
interestHandler := handler.NewInterestHandler(interestService, nil)
// Feature: streak - Initialize streak handler
streakHandler := handler.NewStreakHandler(streakService)
// AI Bookkeeping Service and Handler for Redis setup
aiBookkeepingServiceRedis := service.NewAIBookkeepingService(
cfg,
@@ -523,6 +537,9 @@ func SetupWithRedis(db *gorm.DB, yunAPIClient *service.YunAPIClient, redisClient
// Register notification routes
notificationHandler.RegisterUserRoutes(protected)
notificationHandler.RegisterAdminRoutes(v1)
// Feature: streak - Register streak routes
streakHandler.RegisterRoutes(v1)
}
return r, syncScheduler