2026-01-09 23:18:52 +08:00
|
|
|
import { Module } from '@nestjs/common';
|
|
|
|
|
import { TypeOrmModule } from '@nestjs/typeorm';
|
|
|
|
|
import { ConfigModule, ConfigService } from '@nestjs/config';
|
|
|
|
|
import { BidItem } from '../bids/entities/bid-item.entity';
|
|
|
|
|
import { Keyword } from '../keywords/keyword.entity';
|
2026-01-12 19:50:51 +08:00
|
|
|
import { AiRecommendation } from '../ai/entities/ai-recommendation.entity';
|
2026-01-12 22:48:43 +08:00
|
|
|
import { CrawlInfoAdd } from '../crawler/entities/crawl-info-add.entity';
|
2026-01-09 23:18:52 +08:00
|
|
|
|
|
|
|
|
@Module({
|
|
|
|
|
imports: [
|
|
|
|
|
TypeOrmModule.forRootAsync({
|
|
|
|
|
imports: [ConfigModule],
|
|
|
|
|
inject: [ConfigService],
|
|
|
|
|
useFactory: (configService: ConfigService) => ({
|
|
|
|
|
type: configService.get<any>('DATABASE_TYPE', 'mariadb'),
|
|
|
|
|
host: configService.get<string>('DATABASE_HOST', 'localhost'),
|
|
|
|
|
port: configService.get<number>('DATABASE_PORT', 3306),
|
|
|
|
|
username: configService.get<string>('DATABASE_USERNAME', 'root'),
|
|
|
|
|
password: configService.get<string>('DATABASE_PASSWORD', 'root'),
|
|
|
|
|
database: configService.get<string>('DATABASE_NAME', 'bidding'),
|
2026-01-12 22:48:43 +08:00
|
|
|
entities: [BidItem, Keyword, AiRecommendation, CrawlInfoAdd],
|
2026-01-09 23:18:52 +08:00
|
|
|
synchronize: configService.get<boolean>('DATABASE_SYNCHRONIZE', true),
|
|
|
|
|
}),
|
|
|
|
|
}),
|
|
|
|
|
],
|
|
|
|
|
})
|
|
|
|
|
export class DatabaseModule {}
|