fix(authorization-service): register SystemAccountApplicationService in AppModule

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 <noreply@anthropic.com>
This commit is contained in:
hailin 2026-01-04 22:22:02 -08:00
parent 6e395ce58c
commit e95316c5f4
1 changed files with 124 additions and 106 deletions

View File

@ -1,106 +1,124 @@
import { Module } from '@nestjs/common' import { Module } from '@nestjs/common'
import { ConfigModule } from '@nestjs/config' import { ConfigModule } from '@nestjs/config'
import { ScheduleModule } from '@nestjs/schedule' import { ScheduleModule } from '@nestjs/schedule'
import { PassportModule } from '@nestjs/passport' import { PassportModule } from '@nestjs/passport'
import { JwtModule } from '@nestjs/jwt' import { JwtModule } from '@nestjs/jwt'
// Config // Config
import { appConfig, databaseConfig, redisConfig, kafkaConfig, jwtConfig } from '@/config' import { appConfig, databaseConfig, redisConfig, kafkaConfig, jwtConfig } from '@/config'
// Infrastructure // Infrastructure
import { PrismaService } from '@/infrastructure/persistence/prisma/prisma.service' import { PrismaService } from '@/infrastructure/persistence/prisma/prisma.service'
import { import {
AuthorizationRoleRepositoryImpl, AuthorizationRoleRepositoryImpl,
AUTHORIZATION_ROLE_REPOSITORY, AUTHORIZATION_ROLE_REPOSITORY,
} from '@/infrastructure/persistence/repositories/authorization-role.repository.impl' } from '@/infrastructure/persistence/repositories/authorization-role.repository.impl'
import { import {
MonthlyAssessmentRepositoryImpl, MonthlyAssessmentRepositoryImpl,
MONTHLY_ASSESSMENT_REPOSITORY, MONTHLY_ASSESSMENT_REPOSITORY,
} from '@/infrastructure/persistence/repositories/monthly-assessment.repository.impl' } from '@/infrastructure/persistence/repositories/monthly-assessment.repository.impl'
import { RedisModule } from '@/infrastructure/redis/redis.module' // [2026-01-04] 新增:系统账户仓储,用于系统账户报表统计
import { KafkaModule } from '@/infrastructure/kafka/kafka.module' // 回滚方式:删除此 import 及下方 providers 中的 SYSTEM_ACCOUNT_REPOSITORY 和 SystemAccountApplicationService
import { EventConsumerController } from '@/infrastructure/kafka/event-consumer.controller' import {
import { ReferralServiceClient, IdentityServiceClient, RewardServiceClient } from '@/infrastructure/external' SystemAccountRepositoryImpl,
SYSTEM_ACCOUNT_REPOSITORY,
// Application } from '@/infrastructure/persistence/repositories/system-account.repository.impl'
import { AuthorizationApplicationService, REFERRAL_REPOSITORY, TEAM_STATISTICS_REPOSITORY } from '@/application/services' import { RedisModule } from '@/infrastructure/redis/redis.module'
import { MonthlyAssessmentScheduler } from '@/application/schedulers' import { KafkaModule } from '@/infrastructure/kafka/kafka.module'
import { EventConsumerController } from '@/infrastructure/kafka/event-consumer.controller'
// API import { ReferralServiceClient, IdentityServiceClient, RewardServiceClient } from '@/infrastructure/external'
import {
AuthorizationController, // Application
AdminAuthorizationController, import {
HealthController, AuthorizationApplicationService,
InternalAuthorizationController, SystemAccountApplicationService,
} from '@/api/controllers' REFERRAL_REPOSITORY,
TEAM_STATISTICS_REPOSITORY,
// Shared } from '@/application/services'
import { JwtStrategy } from '@/shared/strategies' import { MonthlyAssessmentScheduler } from '@/application/schedulers'
// Mock repositories for external services (should be replaced with actual implementations) // API
const MockReferralRepository = { import {
provide: REFERRAL_REPOSITORY, AuthorizationController,
useValue: { AdminAuthorizationController,
findByUserId: async () => null, HealthController,
getAllAncestors: async () => [], InternalAuthorizationController,
getAllDescendants: async () => [], } from '@/api/controllers'
},
} // Shared
import { JwtStrategy } from '@/shared/strategies'
@Module({
imports: [ // Mock repositories for external services (should be replaced with actual implementations)
ConfigModule.forRoot({ const MockReferralRepository = {
isGlobal: true, provide: REFERRAL_REPOSITORY,
load: [appConfig, databaseConfig, redisConfig, kafkaConfig, jwtConfig], useValue: {
}), findByUserId: async () => null,
ScheduleModule.forRoot(), getAllAncestors: async () => [],
PassportModule.register({ defaultStrategy: 'jwt' }), getAllDescendants: async () => [],
JwtModule.registerAsync({ },
useFactory: () => ({ }
secret: process.env.JWT_SECRET,
signOptions: { expiresIn: process.env.JWT_EXPIRES_IN || '7d' }, @Module({
}), imports: [
}), ConfigModule.forRoot({
RedisModule, isGlobal: true,
KafkaModule, load: [appConfig, databaseConfig, redisConfig, kafkaConfig, jwtConfig],
], }),
controllers: [ ScheduleModule.forRoot(),
AuthorizationController, PassportModule.register({ defaultStrategy: 'jwt' }),
AdminAuthorizationController, JwtModule.registerAsync({
HealthController, useFactory: () => ({
InternalAuthorizationController, secret: process.env.JWT_SECRET,
EventConsumerController, signOptions: { expiresIn: process.env.JWT_EXPIRES_IN || '7d' },
], }),
providers: [ }),
// Prisma RedisModule,
PrismaService, KafkaModule,
],
// Repositories controllers: [
{ AuthorizationController,
provide: AUTHORIZATION_ROLE_REPOSITORY, AdminAuthorizationController,
useClass: AuthorizationRoleRepositoryImpl, HealthController,
}, InternalAuthorizationController,
{ EventConsumerController,
provide: MONTHLY_ASSESSMENT_REPOSITORY, ],
useClass: MonthlyAssessmentRepositoryImpl, providers: [
}, // Prisma
MockReferralRepository, PrismaService,
// External Service Clients (replaces mock) // Repositories
ReferralServiceClient, {
IdentityServiceClient, provide: AUTHORIZATION_ROLE_REPOSITORY,
RewardServiceClient, useClass: AuthorizationRoleRepositoryImpl,
{ },
provide: TEAM_STATISTICS_REPOSITORY, {
useExisting: ReferralServiceClient, provide: MONTHLY_ASSESSMENT_REPOSITORY,
}, useClass: MonthlyAssessmentRepositoryImpl,
},
// Application Services // [2026-01-04] 新增:系统账户仓储
AuthorizationApplicationService, {
MonthlyAssessmentScheduler, provide: SYSTEM_ACCOUNT_REPOSITORY,
useClass: SystemAccountRepositoryImpl,
// Strategies },
JwtStrategy, MockReferralRepository,
],
}) // External Service Clients (replaces mock)
export class AppModule {} ReferralServiceClient,
IdentityServiceClient,
RewardServiceClient,
{
provide: TEAM_STATISTICS_REPOSITORY,
useExisting: ReferralServiceClient,
},
// Application Services
AuthorizationApplicationService,
// [2026-01-04] 新增:系统账户应用服务,用于系统账户报表统计
SystemAccountApplicationService,
MonthlyAssessmentScheduler,
// Strategies
JwtStrategy,
],
})
export class AppModule {}