diff --git a/BE/src/stock/index/dto/stock.index.response.dto.ts b/BE/src/stock/index/dto/stock.index.response.dto.ts index 358266a5..7f26af32 100644 --- a/BE/src/stock/index/dto/stock.index.response.dto.ts +++ b/BE/src/stock/index/dto/stock.index.response.dto.ts @@ -1,25 +1,28 @@ import { ApiProperty } from '@nestjs/swagger'; -import { StockIndexListElementDto } from './stock.index.list.element.dto'; -import { StockIndexValueElementDto } from './stock.index.value.element.dto'; +import { StockIndexResponseElementDto } from './stock.index.response.element.dto'; export class StockIndexResponseDto { - constructor( - indexList: StockIndexListElementDto[], - indexValue: StockIndexValueElementDto[], - ) { - this.indexList = indexList; - this.indexValue = indexValue; - } + @ApiProperty({ + description: '코스피 지수', + type: StockIndexResponseElementDto, + }) + KOSPI: StockIndexResponseElementDto; + + @ApiProperty({ + description: '코스닥 지수', + type: StockIndexResponseElementDto, + }) + KOSDAQ: StockIndexResponseElementDto; @ApiProperty({ - description: '주가 지수 차트 정보 (코스피, 코스닥, 코스피200, KSQ150)', - type: [StockIndexListElementDto], + description: '코스피200 지수', + type: StockIndexResponseElementDto, }) - indexList: StockIndexListElementDto[]; + KOSPI200: StockIndexResponseElementDto; @ApiProperty({ - description: '주가 지수 실시간 값 정보 (코스피, 코스닥, 코스피200, KSQ150)', - type: [StockIndexValueElementDto], + description: 'KSQ150 지수', + type: StockIndexResponseElementDto, }) - indexValue: StockIndexValueElementDto[]; + KSQ150: StockIndexResponseElementDto; } diff --git a/BE/src/stock/index/dto/stock.index.response.element.dto.ts b/BE/src/stock/index/dto/stock.index.response.element.dto.ts new file mode 100644 index 00000000..7ce0ef1a --- /dev/null +++ b/BE/src/stock/index/dto/stock.index.response.element.dto.ts @@ -0,0 +1,16 @@ +import { ApiProperty } from '@nestjs/swagger'; +import { StockIndexValueElementDto } from './stock.index.value.element.dto'; +import { StockIndexListElementDto } from './stock.index.list.element.dto'; + +export class StockIndexResponseElementDto { + @ApiProperty({ + description: '코스피: 0001, 코스닥: 1001, 코스피200: 2001, KSQ150: 3003', + }) + code: string; + + @ApiProperty({ description: '실시간 값', type: StockIndexValueElementDto }) + value: StockIndexValueElementDto; + + @ApiProperty({ description: '실시간 차트', type: StockIndexListElementDto }) + chart: StockIndexListElementDto; +} diff --git a/BE/src/stock/index/stock.index.controller.ts b/BE/src/stock/index/stock.index.controller.ts index c3ddce59..949df5a5 100644 --- a/BE/src/stock/index/stock.index.controller.ts +++ b/BE/src/stock/index/stock.index.controller.ts @@ -28,45 +28,68 @@ export class StockIndexController { async getStockIndex() { const accessToken = await this.koreaInvestmentService.getAccessToken(); - const stockLists = await Promise.all([ - this.stockIndexService.getDomesticStockIndexListByCode( - '0001', - accessToken, - ), // 코스피 - this.stockIndexService.getDomesticStockIndexListByCode( - '1001', - accessToken, - ), // 코스닥 - this.stockIndexService.getDomesticStockIndexListByCode( - '2001', - accessToken, - ), // 코스피200 - this.stockIndexService.getDomesticStockIndexListByCode( - '3003', - accessToken, - ), // KSQ150 - ]); + const [kospiChart, kosdaqChart, kospi200Chart, ksq150Chart] = + await Promise.all([ + this.stockIndexService.getDomesticStockIndexListByCode( + '0001', + accessToken, + ), // 코스피 + this.stockIndexService.getDomesticStockIndexListByCode( + '1001', + accessToken, + ), // 코스닥 + this.stockIndexService.getDomesticStockIndexListByCode( + '2001', + accessToken, + ), // 코스피200 + this.stockIndexService.getDomesticStockIndexListByCode( + '3003', + accessToken, + ), // KSQ150 + ]); - const stockValues = await Promise.all([ - this.stockIndexService.getDomesticStockIndexValueByCode( - '0001', - accessToken, - ), // 코스피 - this.stockIndexService.getDomesticStockIndexValueByCode( - '1001', - accessToken, - ), // 코스닥 - this.stockIndexService.getDomesticStockIndexValueByCode( - '2001', - accessToken, - ), // 코스피200 - this.stockIndexService.getDomesticStockIndexValueByCode( - '3003', - accessToken, - ), // KSQ150 - ]); + const [kospiValue, kosdaqValue, kospi200Value, ksq150Value] = + await Promise.all([ + this.stockIndexService.getDomesticStockIndexValueByCode( + '0001', + accessToken, + ), // 코스피 + this.stockIndexService.getDomesticStockIndexValueByCode( + '1001', + accessToken, + ), // 코스닥 + this.stockIndexService.getDomesticStockIndexValueByCode( + '2001', + accessToken, + ), // 코스피200 + this.stockIndexService.getDomesticStockIndexValueByCode( + '3003', + accessToken, + ), // KSQ150 + ]); - return new StockIndexResponseDto(stockLists, stockValues); + const stockIndexResponse = new StockIndexResponseDto(); + stockIndexResponse.KOSPI = { + code: '0001', + value: kospiValue, + chart: kospiChart, + }; + stockIndexResponse.KOSDAQ = { + code: '1001', + value: kosdaqValue, + chart: kosdaqChart, + }; + stockIndexResponse.KOSPI200 = { + code: '2001', + value: kospi200Value, + chart: kospi200Chart, + }; + stockIndexResponse.KSQ150 = { + code: '3003', + value: ksq150Value, + chart: ksq150Chart, + }; + return stockIndexResponse; } @Cron('*/5 9-16 * * 1-5')