-
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
[BE] 7.05/7.06 매수/매도 예약 취소 API 구현 #51,#52 #73
Merged
+40
−0
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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 |
---|---|---|
@@ -1,3 +1,9 @@ | ||
import { | ||
ConflictException, | ||
ForbiddenException, | ||
Injectable, | ||
} from '@nestjs/common'; | ||
import { NotFoundError } from 'rxjs'; | ||
import { Injectable } from '@nestjs/common'; | ||
import { StockOrderRequestDto } from './dto/stock-order-request.dto'; | ||
import { StockOrderRepository } from './stock-order.repository'; | ||
|
@@ -33,4 +39,18 @@ export class StockOrderService { | |
|
||
await this.stockOrderRepository.save(order); | ||
} | ||
|
||
async cancel(userId: number, orderId: number) { | ||
const order = await this.stockOrderRepository.findOneBy({ id: orderId }); | ||
|
||
if (!order) throw new NotFoundError('주문을 찾을 수 없습니다.'); | ||
|
||
if (order.user_id !== userId) | ||
throw new ForbiddenException('다른 사용자의 주문은 취소할 수 없습니다.'); | ||
|
||
if (order.status === StatusType.COMPLETE) | ||
throw new ConflictException('이미 체결된 주문은 취소할 수 없습니다.'); | ||
|
||
await this.stockOrderRepository.remove(order); | ||
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. 🟢 이거 그냥 hard delete 하는 건가요? 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. 넵 지금은 hard delete이긴 한뎅 내일 다른 백엔드 분들 이야기 들어보고 결정해보려고 합니당
|
||
} | ||
} |
Unchanged files with check annotations Beta
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
indicator.style.left = `${currentButton.offsetLeft}px`; | ||
indicator.style.width = `${currentButton.offsetWidth}px`; | ||
} | ||
}, [currentMarket]); | ||
return ( | ||
<div className='relative flex gap-1 text-xl font-bold'> |
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.
🟢 이게 가능한 시나리오에서의 에러인가요? 지난 번 학습 스프린트 때 멘토님이 불가능한 상황에 대한 예외처리는 굳이 할 필요가 없다고 하셨던게 생각나서 여쭤봅니다.
로그인한 사용자만 사용할 수 있는 api인 만큼, 토큰으로 해당 사용자의 정보를 구분해서 취소를 할 수 있는데 이게 가능한 시나리오일까..? 하는 생각이 드네요!
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.
음... 프론트엔드랑 연결된 실제 서비스에서는 일어날지 잘 모르겠는데, swagger 여러 명이 같이 사용할 때 혼동이 있을까봐 추가해두긴 했습니다.
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.
하긴 swagger 같은 환경에서는 충분히 혼동이 올 수도 있겠네요.. 제가 너무 실제 환경으로만 생각한 거 같아요! 좋은 의견 감사합니다