-
Notifications
You must be signed in to change notification settings - Fork 1
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
Feature/#184 - 주식을 한글로 검색할 수 있다. #191
Merged
Merged
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
fe5686f
✨ feat: 주식 소유여부 확인
xjfcnfw3 032c1cf
✨ feat: request에서 user를 가져오는 커스텀 데코레이터 구현
xjfcnfw3 e4935a3
✨ feat: http 세션 전용 가드 구현
xjfcnfw3 3d1f90a
✨ feat: 쿠키 이름 설정
xjfcnfw3 e019686
✨ feat: 유저 소유 주식 엔드포인트 가드 적용
xjfcnfw3 aa78d8b
✨ feat: getUser 데코레이터를 인증된 유저 객체만 가져올 수 있도록 변경
xjfcnfw3 843f686
✨ feat: 유저 주식 소유 여부 엔드포인트 구현
xjfcnfw3 0bf13f0
Merge remote-tracking branch 'origin/dev-be' into feature/#158
xjfcnfw3 d2567ce
Merge remote-tracking branch 'origin/dev-be' into feature/#158
xjfcnfw3 24b4229
🐛 fix: 비어있는 쿠키를 받을 때 발생하는 예외 수정
xjfcnfw3 7016782
✨ feat: 특정 종목방의 최신 메시지 리스트 조회 기능 구현
xjfcnfw3 368401c
✨ feat: 종목방에 입장 시 이전 채팅 메시지를 받는다
xjfcnfw3 8b33b3f
♻️ refactor: swagger url 변경
xjfcnfw3 6f19e72
✨ feat: 이전 채팅 스크롤 조회 기능 구현
xjfcnfw3 8c2796e
✨ feat: class dto 내부 타입 자동 변경 설정
xjfcnfw3 f6369d8
✨ feat: 스크롤 크기를 100을 넘지 않도록 설정
xjfcnfw3 e2e3938
✅ test: 100개 초과 메시지 조회에 대한 테스트 코드 작성
xjfcnfw3 d6afa45
Merge branch 'dev-be' of https://github.com/boostcampwm-2024/web17-ju…
xjfcnfw3 42bd4ad
♻️ refactor: swagger url 변경
xjfcnfw3 00a0c06
✨ feat: 이전 채팅 스크롤 조회 기능 구현
xjfcnfw3 d5040cc
✨ feat: class dto 내부 타입 자동 변경 설정
xjfcnfw3 4f6c09f
Merge branch 'feature/#99' into feature/#93
xjfcnfw3 b003c02
✨ feat: 주식 검색 기능 구현
xjfcnfw3 95af1ae
✨ feat: 주식 검색 엔드포인트 구현
xjfcnfw3 35a2afc
✨ feat: swagger 기본 경로 변경
xjfcnfw3 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { Controller, Get, Query } from '@nestjs/common'; | ||
import { | ||
ApiBadRequestResponse, | ||
ApiOkResponse, | ||
ApiOperation, | ||
} from '@nestjs/swagger'; | ||
import { ChatService } from '@/chat/chat.service'; | ||
import { ChatScrollRequest } from '@/chat/dto/chat.request'; | ||
import { ChatScrollResponse } from '@/chat/dto/chat.response'; | ||
|
||
@Controller('chat') | ||
export class ChatController { | ||
constructor(private readonly chatService: ChatService) {} | ||
|
||
@ApiOperation({ | ||
summary: '채팅 스크롤 조회 API', | ||
description: '채팅을 스크롤하여 조회한다.', | ||
}) | ||
@ApiOkResponse({ | ||
description: '스크롤 조회 성공', | ||
type: ChatScrollResponse, | ||
}) | ||
@ApiBadRequestResponse({ | ||
description: '스크롤 크기 100 초과', | ||
example: { | ||
message: 'pageSize should be less than 100', | ||
error: 'Bad Request', | ||
statusCode: 400, | ||
}, | ||
}) | ||
@Get() | ||
async findChatList(@Query() request: ChatScrollRequest) { | ||
return await this.chatService.scrollNextChat( | ||
request.stockId, | ||
request.latestChatId, | ||
request.pageSize, | ||
); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,15 @@ | ||
import { Module } from '@nestjs/common'; | ||
import { TypeOrmModule } from '@nestjs/typeorm'; | ||
import { SessionModule } from '@/auth/session.module'; | ||
import { ChatController } from '@/chat/chat.controller'; | ||
import { ChatGateway } from '@/chat/chat.gateway'; | ||
import { ChatService } from '@/chat/chat.service'; | ||
import { Chat } from '@/chat/domain/chat.entity'; | ||
import { StockModule } from '@/stock/stock.module'; | ||
import { ChatService } from '@/chat/chat.service'; | ||
|
||
@Module({ | ||
imports: [TypeOrmModule.forFeature([Chat]), StockModule, SessionModule], | ||
controllers: [ChatController], | ||
providers: [ChatGateway, ChatService], | ||
}) | ||
export class ChatModule {} |
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,23 @@ | ||
import { DataSource } from 'typeorm'; | ||
import { ChatService } from '@/chat/chat.service'; | ||
import { createDataSourceMock } from '@/user/user.service.spec'; | ||
|
||
describe('ChatService 테스트', () => { | ||
test('첫 스크롤을 조회시 100개 이상 조회하면 예외가 발생한다.', async () => { | ||
const dataSource = createDataSourceMock({}); | ||
const chatService = new ChatService(dataSource as DataSource); | ||
|
||
await expect(() => | ||
chatService.scrollNextChat('A005930', 1, 101), | ||
).rejects.toThrow('pageSize should be less than 100'); | ||
}); | ||
|
||
test('100개 이상의 채팅을 조회하려 하면 예외가 발생한다.', async () => { | ||
const dataSource = createDataSourceMock({}); | ||
const chatService = new ChatService(dataSource as DataSource); | ||
|
||
await expect(() => | ||
chatService.scrollFirstChat('A005930', 101), | ||
).rejects.toThrow('pageSize should be less than 100'); | ||
}); | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,10 @@ | ||
import { Column, Entity, ManyToOne, PrimaryGeneratedColumn } from 'typeorm'; | ||
import { | ||
Column, | ||
Entity, | ||
JoinColumn, | ||
ManyToOne, | ||
PrimaryGeneratedColumn, | ||
} from 'typeorm'; | ||
import { ChatType } from '@/chat/domain/chatType.enum'; | ||
import { DateEmbedded } from '@/common/dateEmbedded.entity'; | ||
import { Stock } from '@/stock/domain/stock.entity'; | ||
|
@@ -10,9 +16,11 @@ export class Chat { | |
id: number; | ||
|
||
@ManyToOne(() => User, (user) => user.id) | ||
@JoinColumn({ name: 'user_id' }) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 아 이거 저도 추가해야하는 데.. 깜박했네요 |
||
user: User; | ||
|
||
@ManyToOne(() => Stock, (stock) => stock.id) | ||
@JoinColumn({ name: 'stock_id' }) | ||
stock: Stock; | ||
|
||
@Column() | ||
|
@@ -25,5 +33,5 @@ export class Chat { | |
likeCount: number = 0; | ||
|
||
@Column(() => DateEmbedded, { prefix: '' }) | ||
date?: DateEmbedded; | ||
date: DateEmbedded; | ||
} |
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,30 @@ | ||
import { ApiProperty } from '@nestjs/swagger'; | ||
import { IsNumber, IsOptional, IsString } from 'class-validator'; | ||
|
||
export class ChatScrollRequest { | ||
@ApiProperty({ | ||
description: '종목 주식 id(종목방 id)', | ||
example: 'A005930', | ||
}) | ||
@IsString() | ||
readonly stockId: string; | ||
|
||
@ApiProperty({ | ||
description: '최신 채팅 id', | ||
example: 99999, | ||
required: false, | ||
}) | ||
@IsOptional() | ||
@IsNumber() | ||
readonly latestChatId?: number; | ||
|
||
@ApiProperty({ | ||
description: '페이지 크기', | ||
example: 20, | ||
default: 20, | ||
required: false, | ||
}) | ||
@IsOptional() | ||
@IsNumber() | ||
readonly pageSize?: number; | ||
} |
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,44 @@ | ||
import { ApiProperty } from '@nestjs/swagger'; | ||
import { Chat } from '@/chat/domain/chat.entity'; | ||
import { ChatType } from '@/chat/domain/chatType.enum'; | ||
|
||
interface ChatResponse { | ||
id: number; | ||
likeCount: number; | ||
message: string; | ||
type: string; | ||
createdAt: Date; | ||
} | ||
|
||
export class ChatScrollResponse { | ||
@ApiProperty({ | ||
description: '다음 페이지가 있는지 여부', | ||
example: true, | ||
}) | ||
readonly hasMore: boolean; | ||
|
||
@ApiProperty({ | ||
description: '채팅 목록', | ||
example: [ | ||
{ | ||
id: 1, | ||
likeCount: 0, | ||
message: '안녕하세요', | ||
type: ChatType.NORMAL, | ||
createdAt: new Date(), | ||
}, | ||
], | ||
}) | ||
readonly chats: ChatResponse[]; | ||
|
||
constructor(chats: Chat[], hasMore: boolean) { | ||
this.chats = chats.map((chat) => ({ | ||
id: chat.id, | ||
likeCount: chat.likeCount, | ||
message: chat.message, | ||
type: chat.type, | ||
createdAt: chat.date!.createdAt, | ||
})); | ||
this.hasMore = hasMore; | ||
} | ||
} |
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
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,12 @@ | ||
import { ApiProperty } from '@nestjs/swagger'; | ||
import { IsNotEmpty, IsString } from 'class-validator'; | ||
|
||
export class StockSearchRequest { | ||
@ApiProperty({ | ||
description: '검색할 단어', | ||
example: '삼성', | ||
}) | ||
@IsNotEmpty() | ||
@IsString() | ||
name: string; | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
만약 외부에서도 사용한다면 다른 파일로 분리하는 게 좋을 거 같아요