From d0b6735984c3aebc26e06e64f5797c3eccf69e9e Mon Sep 17 00:00:00 2001 From: sunghwki Date: Mon, 18 Nov 2024 19:43:57 +0900 Subject: [PATCH 1/3] =?UTF-8?q?=F0=9F=90=9B=20fix:=20scraperModule=20?= =?UTF-8?q?=EC=9D=98=EC=A1=B4=EC=84=B1=20=ED=95=B4=EA=B2=B0,=20bigint=20-\?= =?UTF-8?q?>=20decimal=EB=A1=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/backend/src/app.module.ts | 6 +++--- .../src/scraper/openapi/api/openapiMinuteData.api.ts | 2 +- .../src/scraper/openapi/api/openapiPeriodData.api.ts | 2 +- .../backend/src/scraper/openapi/openapi-scraper.module.ts | 4 +++- .../backend/src/scraper/openapi/openapi-scraper.service.ts | 4 +--- packages/backend/src/stock/domain/stockData.entity.ts | 6 +++--- 6 files changed, 12 insertions(+), 12 deletions(-) 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/scraper/openapi/api/openapiMinuteData.api.ts b/packages/backend/src/scraper/openapi/api/openapiMinuteData.api.ts index 1230a8db..c00dcabf 100644 --- a/packages/backend/src/scraper/openapi/api/openapiMinuteData.api.ts +++ b/packages/backend/src/scraper/openapi/api/openapiMinuteData.api.ts @@ -37,7 +37,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..8253f4ad 100644 --- a/packages/backend/src/scraper/openapi/api/openapiPeriodData.api.ts +++ b/packages/backend/src/scraper/openapi/api/openapiPeriodData.api.ts @@ -174,7 +174,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..b6cfcda7 100644 --- a/packages/backend/src/scraper/openapi/openapi-scraper.module.ts +++ b/packages/backend/src/scraper/openapi/openapi-scraper.module.ts @@ -1,9 +1,11 @@ import { Module } from '@nestjs/common'; +import { OpenapiMinuteData } from './api/openapiMinuteData.api'; +import { OpenapiPeriodData } from './api/openapiPeriodData.api'; import { OpenapiScraperService } from './openapi-scraper.service'; @Module({ imports: [], 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; From 93e7ac3382be3e6d6717cb11abbeb7cb1e11764b Mon Sep 17 00:00:00 2001 From: sunghwki Date: Mon, 18 Nov 2024 19:54:26 +0900 Subject: [PATCH 2/3] =?UTF-8?q?=F0=9F=90=9B=20fix:=20api=20prefix=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/backend/src/main.ts | 2 ++ 1 file changed, 2 insertions(+) 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); From 1d27504c1134e88047795ac31b5148606f2ad04d Mon Sep 17 00:00:00 2001 From: sunghwki Date: Mon, 18 Nov 2024 20:10:27 +0900 Subject: [PATCH 3/3] =?UTF-8?q?=F0=9F=90=9B=20fix:=20typeorm=20=EC=9D=98?= =?UTF-8?q?=EC=A1=B4=EC=84=B1=20=EC=84=A4=EC=B9=98=20=EB=B0=8F=20=ED=95=B4?= =?UTF-8?q?=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/scraper/openapi/api/openapiMinuteData.api.ts | 2 ++ .../src/scraper/openapi/api/openapiPeriodData.api.ts | 4 +++- .../backend/src/scraper/openapi/openapi-scraper.module.ts | 8 +++++++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/packages/backend/src/scraper/openapi/api/openapiMinuteData.api.ts b/packages/backend/src/scraper/openapi/api/openapiMinuteData.api.ts index c00dcabf..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; diff --git a/packages/backend/src/scraper/openapi/api/openapiPeriodData.api.ts b/packages/backend/src/scraper/openapi/api/openapiPeriodData.api.ts index 8253f4ad..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') diff --git a/packages/backend/src/scraper/openapi/openapi-scraper.module.ts b/packages/backend/src/scraper/openapi/openapi-scraper.module.ts index b6cfcda7..00dca421 100644 --- a/packages/backend/src/scraper/openapi/openapi-scraper.module.ts +++ b/packages/backend/src/scraper/openapi/openapi-scraper.module.ts @@ -2,9 +2,15 @@ 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: [OpenapiPeriodData, OpenapiMinuteData, OpenapiScraperService], })