Skip to content

Commit

Permalink
๐Ÿ”ง fix: ์ฃผ๊ฐ€ ์ง€์ˆ˜ API response ํ˜•์‹ ๋ณ€๊ฒฝ
Browse files Browse the repository at this point in the history
  • Loading branch information
sieunie committed Nov 7, 2024
1 parent cf81c6e commit 89420d7
Show file tree
Hide file tree
Showing 3 changed files with 94 additions and 52 deletions.
33 changes: 18 additions & 15 deletions BE/src/stock/index/dto/stock.index.response.dto.ts
Original file line number Diff line number Diff line change
@@ -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;
}
16 changes: 16 additions & 0 deletions BE/src/stock/index/dto/stock.index.response.element.dto.ts
Original file line number Diff line number Diff line change
@@ -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;
}
97 changes: 60 additions & 37 deletions BE/src/stock/index/stock.index.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down

0 comments on commit 89420d7

Please sign in to comment.