Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BE] redis를 사용해 최근 검색어 저장 #105

Merged
merged 25 commits into from
Nov 14, 2024
Merged
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
2ee713d
Merge branch 'back/main' of https://github.com/boostcampwm-2024/web16…
jinddings Nov 13, 2024
ea0afd5
Merge branch 'back/main' of https://github.com/boostcampwm-2024/web16…
jinddings Nov 13, 2024
0afe5b1
✨ feat : redis를 이용해 최근 검색 단어 저장(#57):
jinddings Nov 13, 2024
a617038
✨ feat: API 분리를 위해 chart 전용으로 변경#54
uuuo3o Nov 13, 2024
e23424b
✨ feat: 프론트에서 필요한 값만 반환할 수 있도록 DTO 수정#54
uuuo3o Nov 13, 2024
0203e65
🎨 style: 코드 순서 변경#54
uuuo3o Nov 13, 2024
00677ba
🔥 remove: 불필요한 파일 삭제#54
uuuo3o Nov 13, 2024
383a166
📝 docs: 파일명 변경 및 swagger 문서 수정#54
uuuo3o Nov 13, 2024
463c4cd
➕ add: 차트 그리기에 필요한 값 추가 및 인터페이스 이름 변경#54
uuuo3o Nov 13, 2024
764de7b
🚚 rename: 중복되는 이름 변경#54
uuuo3o Nov 13, 2024
98b8b57
✨ feat: 주식 현재가 API에 사용할 interface, dto 구현#54
uuuo3o Nov 13, 2024
4fe008b
✨ feat: 주식 현재가 API 요청 로직 구현#54
uuuo3o Nov 13, 2024
7dd9da8
♻️ refactor: requestApi 함수 분리 및 불필요한 파일 삭제#55
uuuo3o Nov 13, 2024
6df873c
🚚 rename: 이름을 명확하게 변경#55
uuuo3o Nov 13, 2024
875f2a7
✨ feat: 주식현재가 일자별 API에 사용할 interface, dto 구현#55
uuuo3o Nov 13, 2024
e56921a
✨ feat: 주식현재가 일자별 API 요청 로직 구현#55
uuuo3o Nov 13, 2024
7a61c8d
🚑 !HOTFIX : 도커 컨테이너 시간 설정
jinddings Nov 14, 2024
850e53b
🚑 !HOTFIX : docker 시간 설정 명령어 수정
jinddings Nov 14, 2024
5eb4fc5
🚑 !HOTFIX : docker 시간 설정 명령어 수정
jinddings Nov 14, 2024
e028917
🔧 fix : auth api 경로 변경(#57)
jinddings Nov 14, 2024
d218da8
🚚 rename : redisUtil -> redisDomainService로 클래스 및 파일 이름 변경(#57)
jinddings Nov 14, 2024
3bb0365
✨ feat : 최근 검색어 10 개만 저장하도록 수정(#57)
jinddings Nov 14, 2024
2b2b642
Merge branch 'back/main' into feature/api/stockList-#57
jinddings Nov 14, 2024
b19180c
♻️ refactor : lint 오류 수정(#57)
jinddings Nov 14, 2024
6bd2c54
Merge branch 'feature/api/stockList-#57' of https://github.com/boostc…
jinddings Nov 14, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
🚚 rename: 이름을 명확하게 변경#55
uuuo3o authored and jinddings committed Nov 14, 2024
commit 6df873c831d0a691212bc2943cd5b917b52fe8a8
10 changes: 0 additions & 10 deletions BE/src/stock/trade/history/dto/stock-trade-history-response.dto.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ApiProperty } from '@nestjs/swagger';

export class StockTradeHistoryDataDto {
export class TodayStockTradeHistoryDataDto {
@ApiProperty({ description: '주식 체결 시간' })
stck_cntg_hour: string;

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ApiProperty } from '@nestjs/swagger';

export class StockTradeHistoryOutputDto {
export class TodayStockTradeHistoryOutputDto {
@ApiProperty({ description: '주식 체결 시간' })
stck_cntg_hour: string;

Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { ApiProperty } from '@nestjs/swagger';
import { TodayStockTradeHistoryOutputDto } from './today-stock-trade-history-output.dto';

/**
* 주식현재가 체결 API 응답값 정제 후 FE에 보낼 DTO
*/
export class TodayStockTradeHistoryResponseDto {
@ApiProperty({
type: TodayStockTradeHistoryOutputDto,
description: '상승률 순위',
})
output: TodayStockTradeHistoryOutputDto[];
}
8 changes: 4 additions & 4 deletions BE/src/stock/trade/history/stock-trade-history.controller.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { Controller, Get, Param } from '@nestjs/common';
import { ApiOperation, ApiParam, ApiResponse } from '@nestjs/swagger';
import { StockTradeHistoryService } from './stock-trade-history.service';
import { StockTradeHistoryResponseDto } from './dto/stock-trade-history-response.dto';
import { TodayStockTradeHistoryResponseDto } from './dto/today-stock-trade-history-response.dto';

@Controller('/api/stocks')
export class StockTradeHistoryController {
constructor(
private readonly stockTradeHistoryService: StockTradeHistoryService,
) {}

@Get(':stockCode/trade-history')
@Get(':stockCode/today-trade-history')
@ApiOperation({ summary: '단일 주식 종목에 대한 주식현재가 체결 API' })
@ApiParam({
name: 'stockCode',
@@ -21,9 +21,9 @@ export class StockTradeHistoryController {
@ApiResponse({
status: 200,
description: '단일 주식 종목에 대한 주식현재가 체결값 조회 성공',
type: StockTradeHistoryResponseDto,
type: TodayStockTradeHistoryResponseDto,
})
getStockDetail(@Param('stockCode') stockCode: string) {
return this.stockTradeHistoryService.getStockTradeHistory(stockCode);
return this.stockTradeHistoryService.getTodayStockTradeHistory(stockCode);
}
}
16 changes: 9 additions & 7 deletions BE/src/stock/trade/history/stock-trade-history.service.ts
Original file line number Diff line number Diff line change
@@ -4,8 +4,8 @@ import { KoreaInvestmentService } from '../../../koreaInvestment/korea-investmen
import { getHeader } from '../../../util/get-header';
import { getFullURL } from '../../../util/get-full-URL';
import { InquireCCNLApiResponse } from './interface/Inquire-ccnl.interface';
import { StockTradeHistoryOutputDto } from './dto/stock-trade-history-output.dto';
import { StockTradeHistoryDataDto } from './dto/stock-trade-history-data.dto';
import { TodayStockTradeHistoryOutputDto } from './dto/today-stock-trade-history-output.dto';
import { TodayStockTradeHistoryDataDto } from './dto/today-stock-trade-history-data.dto';

@Injectable()
export class StockTradeHistoryService {
@@ -20,7 +20,7 @@ export class StockTradeHistoryService {
*
* @author uuuo3o
*/
async getStockTradeHistory(stockCode: string) {
async getTodayStockTradeHistory(stockCode: string) {
try {
const queryParams = {
fid_cond_mrkt_div_code: 'J',
@@ -33,7 +33,7 @@ export class StockTradeHistoryService {
queryParams,
);

return this.formatTradeHistoryData(response.output);
return this.formatTodayStockTradeHistoryData(response.output);
} catch (error) {
this.logger.error('API Error Details:', {
status: error.response?.status,
@@ -48,14 +48,16 @@ export class StockTradeHistoryService {

/**
* @private API에서 받은 주식현재가 체결 데이터를 필요한 정보로 정제하는 함수
* @param {StockTradeHistoryOutputDto} infos - API 응답에서 받은 원시 데이터
* @param {TodayStockTradeHistoryOutputDto} infos - API 응답에서 받은 원시 데이터
* @returns - 필요한 정보만 추출한 데이터 배열
*
* @author uuuo3o
*/
private formatTradeHistoryData(infos: StockTradeHistoryOutputDto[]) {
private formatTodayStockTradeHistoryData(
infos: TodayStockTradeHistoryOutputDto[],
) {
return infos.map((info) => {
const infoData = new StockTradeHistoryDataDto();
const infoData = new TodayStockTradeHistoryDataDto();
infoData.stck_cntg_hour = info.stck_cntg_hour;
infoData.stck_prpr = info.stck_prpr;
infoData.prdy_vrss_sign = info.prdy_vrss_sign;