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:
parent
6e395ce58c
commit
e95316c5f4
|
|
@ -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 {}
|
||||
|
|
|
|||
Loading…
Reference in New Issue