-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
8 changed files
with
970 additions
and
2 deletions.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
packages/backend/src/stock/decorator/stockData.decorator.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* eslint-disable @typescript-eslint/naming-convention */ | ||
/* eslint-disable max-lines-per-function */ | ||
|
||
import { applyDecorators } from '@nestjs/common'; | ||
import { ApiOperation, ApiParam, ApiQuery, ApiResponse } from '@nestjs/swagger'; | ||
import { StockDataResponse } from '../dto/stockData.response'; | ||
|
||
export function ApiGetStockData(summary: string, type: string) { | ||
return applyDecorators( | ||
ApiOperation({ summary }), | ||
ApiParam({ | ||
name: 'stockId', | ||
type: String, | ||
description: '주식 ID', | ||
example: 'A005930', | ||
}), | ||
ApiQuery({ | ||
name: 'lastStartTime', | ||
required: false, | ||
description: '마지막 시작 시간 (ISO 8601 형식)', | ||
example: '2024-04-01T00:00:00.000Z', | ||
type: String, | ||
format: 'date-time', | ||
}), | ||
ApiResponse({ | ||
status: 200, | ||
description: `주식의 ${type} 단위 데이터 성공적으로 조회`, | ||
type: StockDataResponse, | ||
}), | ||
ApiResponse({ | ||
status: 404, | ||
description: '주식 데이터가 존재하지 않음', | ||
}), | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { | ||
Entity, | ||
PrimaryGeneratedColumn, | ||
Column, | ||
CreateDateColumn, | ||
JoinColumn, | ||
ManyToOne, | ||
} from 'typeorm'; | ||
import { Stock } from './stock.entity'; | ||
|
||
abstract class StockData { | ||
@PrimaryGeneratedColumn() | ||
id: number; | ||
|
||
@Column({ type: 'decimal', precision: 15, scale: 2 }) | ||
close: number; | ||
|
||
@Column({ type: 'decimal', precision: 15, scale: 2 }) | ||
low: number; | ||
|
||
@Column({ type: 'decimal', precision: 15, scale: 2 }) | ||
high: number; | ||
|
||
@Column({ type: 'decimal', precision: 15, scale: 2 }) | ||
open: number; | ||
|
||
@Column({ type: 'bigint' }) | ||
volume: number; | ||
|
||
@Column({ type: 'timestamp', name: 'start_time' }) | ||
startTime: Date; | ||
|
||
@ManyToOne(() => Stock) | ||
@JoinColumn({ name: 'stock_id' }) | ||
stock: Stock; | ||
|
||
@CreateDateColumn({ name: 'created_at' }) | ||
createdAt: Date; | ||
} | ||
|
||
@Entity('stock_minutely') | ||
export class StockMinutely extends StockData {} | ||
|
||
@Entity('stock_daily') | ||
export class StockDaily extends StockData {} | ||
@Entity('stock_weekly') | ||
export class StockWeekly extends StockData {} | ||
@Entity('stock_monthly') | ||
export class StockMonthly extends StockData {} | ||
@Entity('stock_yearly') | ||
export class StockYearly extends StockData {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import { ApiProperty } from '@nestjs/swagger'; | ||
import { Type } from 'class-transformer'; | ||
|
||
export class PriceDto { | ||
@ApiProperty({ | ||
description: '시작 시간', | ||
type: String, | ||
format: 'date-time', | ||
example: '2024-04-01T00:00:00.000Z', | ||
}) | ||
startTime: Date; | ||
|
||
@ApiProperty({ | ||
description: '시가', | ||
example: '121.00', | ||
}) | ||
open: number; | ||
|
||
@ApiProperty({ | ||
description: '고가', | ||
example: '125.00', | ||
}) | ||
high: number; | ||
|
||
@ApiProperty({ | ||
description: '저가', | ||
example: '120.00', | ||
}) | ||
low: number; | ||
|
||
@ApiProperty({ | ||
description: '종가', | ||
example: '123.45', | ||
}) | ||
close: number; | ||
} | ||
|
||
export class VolumeDto { | ||
@ApiProperty({ | ||
description: '시작 시간', | ||
type: String, | ||
format: 'date-time', | ||
example: '2024-04-01T00:00:00.000Z', | ||
}) | ||
startTime: Date; | ||
|
||
@ApiProperty({ | ||
description: '거래량', | ||
example: 1000, | ||
}) | ||
volume: number; | ||
} | ||
|
||
export class StockDataResponse { | ||
@ApiProperty({ | ||
description: '가격 데이터 배열 (날짜 오름차순)', | ||
type: [PriceDto], | ||
}) | ||
@Type(() => PriceDto) | ||
priceDtoList: PriceDto[]; | ||
|
||
@ApiProperty({ | ||
description: '거래량 데이터 배열 (날짜 오름차순, 색 포함)', | ||
type: [VolumeDto], | ||
}) | ||
@Type(() => VolumeDto) | ||
volumeDtoList: VolumeDto[]; | ||
|
||
@ApiProperty({ | ||
description: '스크롤해서 불러올 수 있는 데이터가 더 존재하는지', | ||
example: true, | ||
}) | ||
hasMore: boolean; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.