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: 게시물 좋아요, 공유 수 올리는 service, controller 계층 구현 #32

Merged
merged 31 commits into from
Aug 26, 2024

Conversation

yerim123456
Copy link
Collaborator

@yerim123456 yerim123456 commented Aug 25, 2024

🎟️ 관련 이슈

Resolves #22

👩‍💻 구현 내용

  • 게시물 좋아요, 공유 수 올리는 service, controller 계층 구현
  • 게시물 좋아요, 공유 수 올리는 service 테스트 코드 작성
  • 게시물 좋아요, 공유 수 올리는 docs 작성
  • 비동기 처리를 위한 event 정의 및 리스너 구현

💬 코멘트

  • 커스텀 에러를 핸들러가 잡지 못해서 @RestControllerAdvice GlobalExceptionHandler에 추가하였습니다.

💭 고려한 점

  • 같은 데이터를 받아 처리하는 거지만, 다른 이벤트임을 명시해주기 위해 Like와 Share의 이벤트를 각각 따로 정의했습니다.

@yerim123456 yerim123456 added the 💫 enhancement New feature or request label Aug 25, 2024
@yerim123456 yerim123456 self-assigned this Aug 25, 2024
Copy link

📊 Jacoco Test Coverage

Overall Project 17.84% -4.03% 🍏
Files changed 55.97% 🍏

File Coverage
Post.java 100% 🍏
PostService.java 90% -10% 🍏
StatusCode.java 90% 🍏
IntegratedFeedBackendApplication.java 37.5% 🍏
PostEventListener.java 9.09% -90.91% 🍏
GlobalExceptionHandler.java 2.58% 🍏
PostController.java 0% -53.85% 🍏

jooda00
jooda00 previously approved these changes Aug 25, 2024
Copy link
Collaborator

@jooda00 jooda00 left a comment

Choose a reason for hiding this comment

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

고생하셨습니다! 전체적으로 코드를 깔끔하게 작성해주셔서 리뷰하면서 이해하기 쉬워서 좋았습니다👍
approve 할게요🤗

@@ -28,4 +34,20 @@ public BaseApiResponse<PostSearchRes> getPosts(
return new BaseApiResponse<>(HttpStatus.OK, StatusCode.OK.getMessage(), res);
}

// 좋아요 수 증가시키는 api
@ResponseStatus(HttpStatus.OK)
@PatchMapping("/{postId}/like")
Copy link
Collaborator

Choose a reason for hiding this comment

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

💭 잘은 모르지만 저희 like로 단수형일까요?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

넵! 저번에 테크스택 작성할 때 그렇게 작성했어서 우선 저렇게 해두었습니다! 혹시 복수형으로 변경하는 게 더 좋을까요?

Copy link
Collaborator

Choose a reason for hiding this comment

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

엇 아니요! 제가 잘 몰라서 여쭤본거라 편하게 해주셔도 좋을 것 같아요☺️

@Service
@Transactional(readOnly = true)
@RequiredArgsConstructor
@Slf4j
Copy link
Collaborator

Choose a reason for hiding this comment

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

PostService에서는 아직 log를 안 찍으시는 것 같은데 혹시 다른 용도로 넣으신건지 궁금합니다!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

아 지워두겠습니다! log 찍어보고 안 지웠나봐요! 감사합니다:)

Copy link

📊 Jacoco Test Coverage

Overall Project 21.75% -1.28% 🍏
Files changed 87.82% 🍏

File Coverage
PostEventListener.java 100% 🍏
Post.java 100% 🍏
PostEventPublisher.java 100% 🍏
StatusCode.java 90% 🍏
PostService.java 88.64% -11.36% 🍏
GlobalExceptionHandler.java 2.58% 🍏
PostController.java 0% -53.85% 🍏

Copy link

📊 Jacoco Test Coverage

Overall Project 21.54% -1.28% 🍏
Files changed 87.5% 🍏

File Coverage
PostEventListener.java 100% 🍏
Post.java 100% 🍏
PostEventPublisher.java 100% 🍏
StatusCode.java 90% 🍏
PostService.java 87.5% -12.5% 🍏
GlobalExceptionHandler.java 2.58% 🍏
PostController.java 0% -53.85% 🍏

Copy link

📊 Jacoco Test Coverage

Overall Project 21.54% -1.28% 🍏
Files changed 87.5% 🍏

File Coverage
PostEventListener.java 100% 🍏
Post.java 100% 🍏
PostEventPublisher.java 100% 🍏
StatusCode.java 90% 🍏
PostService.java 87.5% -12.5% 🍏
GlobalExceptionHandler.java 2.58% 🍏
PostController.java 0% -53.85% 🍏

Comment on lines 28 to 32
// 외부 API 호출
facebookAdapter.increaseLikeCount(postId);
twitterAdapter.increaseLikeCount(postId);
instagramAdapter.increaseLikeCount(postId);
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

🚨
각 포스트의 타입의 맞는 api를 호출해야될것 같아요
그리고 스레드가 빠져있습니다!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

말씀해주셔서 감사합니다! 해당 부분 수정했습니다.
ff94cb2

Copy link
Collaborator

Choose a reason for hiding this comment

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

스레드 아직 추가 안된 것 같아요!

Copy link
Collaborator

@hye-on hye-on left a comment

Choose a reason for hiding this comment

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

고생하셨습니다 👍

Copy link
Collaborator

@uijin-j uijin-j left a comment

Choose a reason for hiding this comment

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

테스트가 깔끔하네용!👍🏻 많이 배워갑니다☺️

Copy link

📊 Jacoco Test Coverage

Overall Project 20.64% -3.02% 🍏
Files changed 73.08% 🍏

File Coverage
Post.java 100% 🍏
PostEventPublisher.java 100% 🍏
PostService.java 88.64% -11.36% 🍏
PostEventListener.java 60.53% -39.47% 🍏
IntegratedFeedBackendApplication.java 37.5% 🍏
GlobalExceptionHandler.java 2.58% 🍏
PostController.java 0% -53.85% 🍏

Copy link

📊 Jacoco Test Coverage

Overall Project 23.69% -2.41% 🍏
Files changed 74.21% 🍏

File Coverage
Post.java 100% 🍏
PostEventPublisher.java 100% 🍏
StatusCode.java 92.86% 🍏
PostService.java 88.64% -11.36% 🍏
PostEventListener.java 60.53% -39.47% 🍏
IntegratedFeedBackendApplication.java 37.5% 🍏
GlobalExceptionHandler.java 2.45% 🍏
PostController.java 0% -53.85% 🍏

@yerim123456 yerim123456 merged commit 22af3a2 into main Aug 26, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
💫 enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

게시물 좋아요, 공유 API 의 Event 작성
4 participants