Skip to content

Conversation

@leesewon00
Copy link
Member

관련 이슈

작업 내용

  • 게시글 좋아요 관련된 API 구현하였습니다.

    • 게시글 좋아요 작성 API
    • 게시글 좋아요 삭제 API
  • 테스트코드 작성하였습니다.

모든 테스트 정상동작 합니다.

image

특이 사항

게시글 좋아요 수 갱신 시점에 동시성 이슈 발생하여 내용 작성하였습니다.
게시글_좋아요_고찰.docx

특정 게시글 조회시 isLiked 값도 반환하도록 수정하였습니다.

리뷰 요구사항 (선택)

@leesewon00 leesewon00 self-assigned this Aug 17, 2024
@leesewon00 leesewon00 requested a review from nayonsoso August 17, 2024 08:40
Copy link
Collaborator

@nayonsoso nayonsoso left a comment

Choose a reason for hiding this comment

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

워낙 코드를 잘 짜주셔서 ㅎㅎ 이번엔 리뷰할게 별로 없었네요!
작업하시느라 수고 많으셨습니다🥳


[정말로 궁금해서 묻는 질문]
'게시글 좋아요 / 좋아요 취소를 하나의 API 에서 한다'는 선택지도 있었을텐데
왜 API 를 따로 만드셨나 궁금해요!

Comment on lines +112 to +115
void 게시글_좋아요_동시성_문제를_해결한다() throws InterruptedException {

ExecutorService executorService = Executors.newFixedThreadPool(THREAD_POOL_SIZE);
CountDownLatch doneSignal = new CountDownLatch(THREAD_NUMS);
Copy link
Collaborator

Choose a reason for hiding this comment

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

동시성 테스트..!😲👏

Comment on lines +5 to +7
public record PostLikeResponse(
Long likeCount,
Boolean isLiked
Copy link
Collaborator

Choose a reason for hiding this comment

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

[반영 안 해도 되는 개인적 생각]
래퍼 클래스는 "null 이 올 가능성이 있을 때" 만 사용하는 것이 좋다 생각해요. 메모리상으로도 효율적이고, 다른 개발자들에게 null 의 가능성을 알려준다는 것도 중요하다 생각해서요!

Copy link
Member Author

@leesewon00 leesewon00 Aug 18, 2024

Choose a reason for hiding this comment

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

오,, 해당부분은 제가 크게 놓치고 있었던 내용이네요,,
래퍼클래스의 장점 때문에 무분별하게 사용하고 있었던 것 같은데 null이 올 가능성이 없을때 등 불필요한 상황에서의 래퍼클래스 사용은 지양하는게 좋다는 생각이 드네요. 감사합니다!

@leesewon00
Copy link
Member Author

[정말로 궁금해서 묻는 질문] '게시글 좋아요 / 좋아요 취소를 하나의 API 에서 한다'는 선택지도 있었을텐데 왜 API 를 따로 만드셨나 궁금해요!

단순히 게시글의 좋아요 수를 +-1 하는것 뿐만아니라, 추후 '내가 좋아요한 게시글 조회' 등과 같은 기능확장을 위해서
db에 관계를 저장하고 삭제하는 작업이 진행되기 때문에, 두 기능이 서로 다른 책임을 가지고 있다고 생각하여 분리하였습니다.

@leesewon00 leesewon00 merged commit 04c0eed into solid-connection:main Aug 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

게시글 좋아요 API 구현

2 participants