From e95316c5f49e9c01e9ba9f1fe85f1ea47a49e5ab Mon Sep 17 00:00:00 2001 From: hailin Date: Sun, 4 Jan 2026 22:22:02 -0800 Subject: [PATCH] fix(authorization-service): register SystemAccountApplicationService in AppModule MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add missing dependency injection for SystemAccountApplicationService which is required by InternalAuthorizationController for system account report statistics API. - Import SystemAccountRepositoryImpl and SYSTEM_ACCOUNT_REPOSITORY - Register SystemAccountApplicationService as provider - Register SYSTEM_ACCOUNT_REPOSITORY with SystemAccountRepositoryImpl 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- .../authorization-service/src/app.module.ts | 230 ++++++++++-------- 1 file changed, 124 insertions(+), 106 deletions(-) diff --git a/backend/services/authorization-service/src/app.module.ts b/backend/services/authorization-service/src/app.module.ts index 3a0d0210..c14216b5 100644 --- a/backend/services/authorization-service/src/app.module.ts +++ b/backend/services/authorization-service/src/app.module.ts @@ -1,106 +1,124 @@ -import { Module } from '@nestjs/common' -import { ConfigModule } from '@nestjs/config' -import { ScheduleModule } from '@nestjs/schedule' -import { PassportModule } from '@nestjs/passport' -import { JwtModule } from '@nestjs/jwt' - -// Config -import { appConfig, databaseConfig, redisConfig, kafkaConfig, jwtConfig } from '@/config' - -// Infrastructure -import { PrismaService } from '@/infrastructure/persistence/prisma/prisma.service' -import { - AuthorizationRoleRepositoryImpl, - AUTHORIZATION_ROLE_REPOSITORY, -} from '@/infrastructure/persistence/repositories/authorization-role.repository.impl' -import { - MonthlyAssessmentRepositoryImpl, - MONTHLY_ASSESSMENT_REPOSITORY, -} from '@/infrastructure/persistence/repositories/monthly-assessment.repository.impl' -import { RedisModule } from '@/infrastructure/redis/redis.module' -import { KafkaModule } from '@/infrastructure/kafka/kafka.module' -import { EventConsumerController } from '@/infrastructure/kafka/event-consumer.controller' -import { ReferralServiceClient, IdentityServiceClient, RewardServiceClient } from '@/infrastructure/external' - -// Application -import { AuthorizationApplicationService, REFERRAL_REPOSITORY, TEAM_STATISTICS_REPOSITORY } from '@/application/services' -import { MonthlyAssessmentScheduler } from '@/application/schedulers' - -// API -import { - AuthorizationController, - AdminAuthorizationController, - HealthController, - InternalAuthorizationController, -} from '@/api/controllers' - -// Shared -import { JwtStrategy } from '@/shared/strategies' - -// Mock repositories for external services (should be replaced with actual implementations) -const MockReferralRepository = { - provide: REFERRAL_REPOSITORY, - useValue: { - findByUserId: async () => null, - getAllAncestors: async () => [], - getAllDescendants: async () => [], - }, -} - -@Module({ - imports: [ - ConfigModule.forRoot({ - isGlobal: true, - load: [appConfig, databaseConfig, redisConfig, kafkaConfig, jwtConfig], - }), - ScheduleModule.forRoot(), - PassportModule.register({ defaultStrategy: 'jwt' }), - JwtModule.registerAsync({ - useFactory: () => ({ - secret: process.env.JWT_SECRET, - signOptions: { expiresIn: process.env.JWT_EXPIRES_IN || '7d' }, - }), - }), - RedisModule, - KafkaModule, - ], - controllers: [ - AuthorizationController, - AdminAuthorizationController, - HealthController, - InternalAuthorizationController, - EventConsumerController, - ], - providers: [ - // Prisma - PrismaService, - - // Repositories - { - provide: AUTHORIZATION_ROLE_REPOSITORY, - useClass: AuthorizationRoleRepositoryImpl, - }, - { - provide: MONTHLY_ASSESSMENT_REPOSITORY, - useClass: MonthlyAssessmentRepositoryImpl, - }, - MockReferralRepository, - - // External Service Clients (replaces mock) - ReferralServiceClient, - IdentityServiceClient, - RewardServiceClient, - { - provide: TEAM_STATISTICS_REPOSITORY, - useExisting: ReferralServiceClient, - }, - - // Application Services - AuthorizationApplicationService, - MonthlyAssessmentScheduler, - - // Strategies - JwtStrategy, - ], -}) -export class AppModule {} +import { Module } from '@nestjs/common' +import { ConfigModule } from '@nestjs/config' +import { ScheduleModule } from '@nestjs/schedule' +import { PassportModule } from '@nestjs/passport' +import { JwtModule } from '@nestjs/jwt' + +// Config +import { appConfig, databaseConfig, redisConfig, kafkaConfig, jwtConfig } from '@/config' + +// Infrastructure +import { PrismaService } from '@/infrastructure/persistence/prisma/prisma.service' +import { + AuthorizationRoleRepositoryImpl, + AUTHORIZATION_ROLE_REPOSITORY, +} from '@/infrastructure/persistence/repositories/authorization-role.repository.impl' +import { + MonthlyAssessmentRepositoryImpl, + MONTHLY_ASSESSMENT_REPOSITORY, +} from '@/infrastructure/persistence/repositories/monthly-assessment.repository.impl' +// [2026-01-04] 新增:系统账户仓储,用于系统账户报表统计 +// 回滚方式:删除此 import 及下方 providers 中的 SYSTEM_ACCOUNT_REPOSITORY 和 SystemAccountApplicationService +import { + SystemAccountRepositoryImpl, + SYSTEM_ACCOUNT_REPOSITORY, +} from '@/infrastructure/persistence/repositories/system-account.repository.impl' +import { RedisModule } from '@/infrastructure/redis/redis.module' +import { KafkaModule } from '@/infrastructure/kafka/kafka.module' +import { EventConsumerController } from '@/infrastructure/kafka/event-consumer.controller' +import { ReferralServiceClient, IdentityServiceClient, RewardServiceClient } from '@/infrastructure/external' + +// Application +import { + AuthorizationApplicationService, + SystemAccountApplicationService, + REFERRAL_REPOSITORY, + TEAM_STATISTICS_REPOSITORY, +} from '@/application/services' +import { MonthlyAssessmentScheduler } from '@/application/schedulers' + +// API +import { + AuthorizationController, + AdminAuthorizationController, + HealthController, + InternalAuthorizationController, +} from '@/api/controllers' + +// Shared +import { JwtStrategy } from '@/shared/strategies' + +// Mock repositories for external services (should be replaced with actual implementations) +const MockReferralRepository = { + provide: REFERRAL_REPOSITORY, + useValue: { + findByUserId: async () => null, + getAllAncestors: async () => [], + getAllDescendants: async () => [], + }, +} + +@Module({ + imports: [ + ConfigModule.forRoot({ + isGlobal: true, + load: [appConfig, databaseConfig, redisConfig, kafkaConfig, jwtConfig], + }), + ScheduleModule.forRoot(), + PassportModule.register({ defaultStrategy: 'jwt' }), + JwtModule.registerAsync({ + useFactory: () => ({ + secret: process.env.JWT_SECRET, + signOptions: { expiresIn: process.env.JWT_EXPIRES_IN || '7d' }, + }), + }), + RedisModule, + KafkaModule, + ], + controllers: [ + AuthorizationController, + AdminAuthorizationController, + HealthController, + InternalAuthorizationController, + EventConsumerController, + ], + providers: [ + // Prisma + PrismaService, + + // Repositories + { + provide: AUTHORIZATION_ROLE_REPOSITORY, + useClass: AuthorizationRoleRepositoryImpl, + }, + { + provide: MONTHLY_ASSESSMENT_REPOSITORY, + useClass: MonthlyAssessmentRepositoryImpl, + }, + // [2026-01-04] 新增:系统账户仓储 + { + provide: SYSTEM_ACCOUNT_REPOSITORY, + useClass: SystemAccountRepositoryImpl, + }, + MockReferralRepository, + + // External Service Clients (replaces mock) + ReferralServiceClient, + IdentityServiceClient, + RewardServiceClient, + { + provide: TEAM_STATISTICS_REPOSITORY, + useExisting: ReferralServiceClient, + }, + + // Application Services + AuthorizationApplicationService, + // [2026-01-04] 新增:系统账户应用服务,用于系统账户报表统计 + SystemAccountApplicationService, + MonthlyAssessmentScheduler, + + // Strategies + JwtStrategy, + ], +}) +export class AppModule {}