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

[feat #186] 질문글 삭제 API #187

Open
wants to merge 9 commits into
base: dev
Choose a base branch
from

Conversation

hyun2371
Copy link
Member

@hyun2371 hyun2371 commented Jan 5, 2025

관련 이슈

📑 작업 상세 내용

  • 질문글 삭제 API
    • 해당 질문글에 답변이 달리지 않았을 경우 삭제 가능
    • 삭제 후 질문 등록 시 걸었던 금액 반환

💫 작업 요약

  • 질문글 삭제 API 추가 및 테스트 수행

🔍 중점적으로 리뷰 할 부분

  • 환불하는 함수가 추가로 생겨, 질문 자동마감 시 환불하는 함수명을 refundClosedQuestionPosts()로 수정했습니다.
  • 질문 마감, 질문 삭제 시 creditHistory에 저장하는 로직이 똑같아서 함수로 추출했습니다.

@hyun2371 hyun2371 added the ✨ feat 기능 추가 label Jan 5, 2025
@hyun2371 hyun2371 requested a review from dudxo January 5, 2025 06:55
@hyun2371 hyun2371 self-assigned this Jan 5, 2025
@hyun2371 hyun2371 linked an issue Jan 5, 2025 that may be closed by this pull request
1 task
Copy link

github-actions bot commented Jan 5, 2025

Code Coverage

Overall Project 83.83% -0.24% 🍏
Files changed 83.54% 🍏

File Coverage
QuestionPostController.java 100% 🍏
QuestionPostService.java 83.4% -5.14% 🍏

Copy link

github-actions bot commented Jan 5, 2025

Test Results

 28 files   28 suites   14s ⏱️
140 tests 138 ✅ 2 💤 0 ❌
141 runs  139 ✅ 2 💤 0 ❌

Results for commit c92e825.

Copy link
Collaborator

@dudxo dudxo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

고생하셨습니다!

작성자 유효성 검증이 없어서 추가 후 승인하겠습니다!

public DeleteQuestionPostResponse deleteQuestionPost(
Long questionPostId
){
QuestionPost questionPost = questionPostRepository.findById(questionPostId)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

작성자 본인의 게시글이 맞는지 확인하는 유효성 검사가 누락 되어있습니다!

){
QuestionPost questionPost = questionPostRepository.findById(questionPostId)
.orElseThrow(() -> new NotFoundException(QuestionPostErrorCode.NOT_FOUND_QUESTION_POST));
if (answerRepository.existsByQuestionPostId(questionPostId)) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

여기도 메서드 추출하면 깔끔해질 것 같아요!

});
}

private void saveRefundCreditHistory(Member member, int reward){
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍


//when & then
assertThrows(ValidationException.class,
() -> questionPostService.deleteQuestionPost(questionPostId));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

삭제할 수 없을 때 발생하는 예외 문구가 의도와 맞는지 확인하면 더 좋은 테스트 코드가 될 것 같아요!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✨ feat 기능 추가
Projects
None yet
Development

Successfully merging this pull request may close these issues.

✨ 질문글 삭제 API
2 participants