diff --git a/packages/backend/src/app.module.ts b/packages/backend/src/app.module.ts index 38332da4..d0c5f81d 100644 --- a/packages/backend/src/app.module.ts +++ b/packages/backend/src/app.module.ts @@ -1,6 +1,9 @@ import { Module } from '@nestjs/common'; +import { ConfigModule } from '@nestjs/config'; +import { ScheduleModule } from '@nestjs/schedule'; import { TypeOrmModule } from '@nestjs/typeorm'; import { WinstonModule } from 'nest-winston'; +import { ScraperModule } from './scraper/scraper.module'; import { AuthModule } from '@/auth/auth.module'; import { SessionModule } from '@/auth/session.module'; import { ChatModule } from '@/chat/chat.module'; @@ -11,9 +14,6 @@ import { import { logger } from '@/configs/logger.config'; import { StockModule } from '@/stock/stock.module'; import { UserModule } from '@/user/user.module'; -import { ScraperModule } from './scraper/scraper.module'; -import { ScheduleModule } from '@nestjs/schedule'; -import { ConfigModule } from '@nestjs/config'; @Module({ imports: [ diff --git a/packages/backend/src/main.ts b/packages/backend/src/main.ts index 311bcdb9..14613072 100644 --- a/packages/backend/src/main.ts +++ b/packages/backend/src/main.ts @@ -10,6 +10,8 @@ import { useSwagger } from '@/configs/swagger.config'; async function bootstrap() { const app = await NestFactory.create(AppModule); const store = app.get(MEMORY_STORE); + + app.setGlobalPrefix('api'); app.use(session({ ...sessionConfig, store })); app.useGlobalPipes(new ValidationPipe({ transform: true })); useSwagger(app); diff --git a/packages/backend/src/scraper/openapi/api/openapiMinuteData.api.ts b/packages/backend/src/scraper/openapi/api/openapiMinuteData.api.ts index 1230a8db..cbc43334 100644 --- a/packages/backend/src/scraper/openapi/api/openapiMinuteData.api.ts +++ b/packages/backend/src/scraper/openapi/api/openapiMinuteData.api.ts @@ -10,7 +10,9 @@ import { import { openApiToken } from './openapiToken.api'; import { Stock } from '@/stock/domain/stock.entity'; import { StockData, StockMinutely } from '@/stock/domain/stockData.entity'; +import { Injectable } from '@nestjs/common'; +@Injectable() export class OpenapiMinuteData { private stock: Stock[]; private readonly entity = StockMinutely; @@ -37,7 +39,7 @@ export class OpenapiMinuteData { stockPeriod.open = parseInt(item.stck_oprc); stockPeriod.high = parseInt(item.stck_hgpr); stockPeriod.low = parseInt(item.stck_lwpr); - stockPeriod.volume = BigInt(item.cntg_vol); + stockPeriod.volume = parseInt(item.cntg_vol); stockPeriod.createdAt = new Date(); return stockPeriod; } diff --git a/packages/backend/src/scraper/openapi/api/openapiPeriodData.api.ts b/packages/backend/src/scraper/openapi/api/openapiPeriodData.api.ts index a11766b6..74526d54 100644 --- a/packages/backend/src/scraper/openapi/api/openapiPeriodData.api.ts +++ b/packages/backend/src/scraper/openapi/api/openapiPeriodData.api.ts @@ -16,6 +16,7 @@ import { StockMonthly, StockYearly, } from '@/stock/domain/stockData.entity'; +import { Injectable } from '@nestjs/common'; const DATE_TO_ENTITY = { D: StockDaily, @@ -33,11 +34,12 @@ const DATE_TO_MONTH = { const INTERVALS = 4000; +@Injectable() export class OpenapiPeriodData { private readonly url: string = '/uapi/domestic-stock/v1/quotations/inquire-daily-itemchartprice'; public constructor(private readonly datasourse: DataSource) { - //this.getItemChartPriceCheck(); + this.getItemChartPriceCheck(); } @Cron('0 1 * * 1-5') @@ -174,7 +176,7 @@ export class OpenapiPeriodData { stockPeriod.open = parseInt(item.stck_oprc); stockPeriod.high = parseInt(item.stck_hgpr); stockPeriod.low = parseInt(item.stck_lwpr); - stockPeriod.volume = BigInt(item.acml_vol); + stockPeriod.volume = parseInt(item.acml_vol); stockPeriod.createdAt = new Date(); await this.insertChartData(stockPeriod, entity); } diff --git a/packages/backend/src/scraper/openapi/openapi-scraper.module.ts b/packages/backend/src/scraper/openapi/openapi-scraper.module.ts index 7f272bd9..00dca421 100644 --- a/packages/backend/src/scraper/openapi/openapi-scraper.module.ts +++ b/packages/backend/src/scraper/openapi/openapi-scraper.module.ts @@ -1,9 +1,17 @@ import { Module } from '@nestjs/common'; +import { OpenapiMinuteData } from './api/openapiMinuteData.api'; +import { OpenapiPeriodData } from './api/openapiPeriodData.api'; import { OpenapiScraperService } from './openapi-scraper.service'; +import { DataSource } from 'typeorm'; +import { TypeOrmModule } from '@nestjs/typeorm'; +import { Stock } from '@/stock/domain/stock.entity'; +import { StockDaily, StockMinutely, StockMonthly, StockWeekly, StockYearly } from '@/stock/domain/stockData.entity'; +import { StockLiveData } from '@/stock/domain/stockLiveData.entity'; +import { StockDetail } from '@/stock/domain/stockDetail.entity'; @Module({ - imports: [], + imports: [TypeOrmModule.forFeature([Stock, StockMinutely , StockDaily, StockWeekly, StockMonthly, StockYearly, StockLiveData, StockDetail])], controllers: [], - providers: [OpenapiScraperService], + providers: [OpenapiPeriodData, OpenapiMinuteData, OpenapiScraperService], }) export class OpenapiScraperModule {} diff --git a/packages/backend/src/scraper/openapi/openapi-scraper.service.ts b/packages/backend/src/scraper/openapi/openapi-scraper.service.ts index 5b638c67..98f27a34 100644 --- a/packages/backend/src/scraper/openapi/openapi-scraper.service.ts +++ b/packages/backend/src/scraper/openapi/openapi-scraper.service.ts @@ -1,6 +1,5 @@ -import { Inject, Injectable } from '@nestjs/common'; +import { Injectable } from '@nestjs/common'; import { DataSource } from 'typeorm'; -import { Logger } from 'winston'; import { OpenapiMinuteData } from './api/openapiMinuteData.api'; import { OpenapiPeriodData } from './api/openapiPeriodData.api'; @@ -10,6 +9,5 @@ export class OpenapiScraperService { private readonly datasourse: DataSource, private readonly openapiPeriodData: OpenapiPeriodData, private readonly openapiMinuteData: OpenapiMinuteData, - @Inject('winston') private readonly logger: Logger, ) {} } diff --git a/packages/backend/src/stock/domain/stockData.entity.ts b/packages/backend/src/stock/domain/stockData.entity.ts index 55395ffd..e9c75407 100644 --- a/packages/backend/src/stock/domain/stockData.entity.ts +++ b/packages/backend/src/stock/domain/stockData.entity.ts @@ -1,3 +1,4 @@ +import { applyDecorators } from '@nestjs/common'; import { Entity, PrimaryGeneratedColumn, @@ -8,7 +9,6 @@ import { ColumnOptions, } from 'typeorm'; import { Stock } from './stock.entity'; -import { applyDecorators } from '@nestjs/common'; export const GenerateBigintColumn = ( options?: ColumnOptions, @@ -43,8 +43,8 @@ export class StockData { @Column({ type: 'decimal', precision: 15, scale: 2 }) open: number; - @GenerateBigintColumn() - volume: BigInt; + @Column({ type: 'decimal', precision: 15, scale: 2 }) + volume: number; @Column({ type: 'timestamp', name: 'start_time' }) startTime: Date;