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

[BE] 체크리스트 좋아요 서비스 구조를 분리한다. #607

Merged
merged 10 commits into from
Sep 21, 2024

Conversation

tkdgur0906
Copy link
Contributor

@tkdgur0906 tkdgur0906 commented Sep 17, 2024

❗ Issue

✨ 구현한 기능

  • 체크리스트 좋아요 관련 기능 서비스 구조 변경

📢 논의하고 싶은 내용

체크리스트 목록 좋아요 필터링 기능을 다음과 같은 순서로 구현하려고 시도했습니다.

  1. 사용자의 체크리스트 좋아요 목록 조회
  2. 해당 좋아요 목록으로 체크리스트 목록 조회

하지만 ChecklistLike가 User를 가지고 있지 않아 Checklist, User와 join을 해야했습니다.
해당 방식도 동일한 join을 해야하기 때문에 기존 코드를 그대로 가져가는게 좋을 것 같아 유지했습니다.
다른 의견 있으시면 말씀해주세요!

🎸 기타

Copy link
Contributor

@tsulocalize tsulocalize 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
Contributor

@JINU-CHANG JINU-CHANG left a comment

Choose a reason for hiding this comment

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

논의하고 싶은 내용에 적힌 내용이 ChecklistRepository의 findAllByUserAndIsLiked 관련 내용이죠? 저는 좋은 것 같습니다 이 방식이 더 직관적이고 이해하기 쉬운 것 같아요 👍

카피 수고많으셨습니다 😃

Comment on lines 28 to 31
private void validateChecklistLike(User user, Checklist checklist) {
validateChecklistOwnership(user, checklist);
validateChecklistAlreadyLiked(checklist);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

메서드가 2개면 굳이 묶을 필요없다고 생각해요! createLike() 내에 두면 파악이 좀 더 쉬울 것 같아요~

Copy link
Contributor Author

Choose a reason for hiding this comment

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

넵 반영했습니다~

@Transactional
public void deleteLike(User user, Checklist checklist) {
validateChecklistOwnership(user, checklist);
ChecklistLike checklistLike = checklistLikeRepository.getByChecklistId(checklist.getId());
Copy link
Contributor

Choose a reason for hiding this comment

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

repository 메서드 파라미터 타입 long -> Long으로 변경부탁드려요 !


//then
assertAll(
() -> assertThat(response.checklists().size()).isEqualTo(2),
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
() -> assertThat(response.checklists().size()).isEqualTo(2),
() -> assertThat(response.checklists().size()).hasSize(2),

2 상수로 빼면 좋을 것 같아요!

@Autowired
private ChecklistLikeRepository checklistLikeRepository;

@DisplayName("체크리스트 좋아요 추가 성공")
Copy link
Contributor

Choose a reason for hiding this comment

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

테스트 꼼꼼하게 작성해주셨네요 👍👍

Copy link
Contributor

@shin-jisong shin-jisong left a comment

Choose a reason for hiding this comment

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

카피 꼼꼼히 해 주셔서 리뷰할 게 많지 않네요! ㅎㅎ

@@ -3,6 +3,8 @@
import com.bang_ggood.checklist.domain.Checklist;
import com.bang_ggood.checklist.dto.request.ChecklistRequest;
import com.bang_ggood.checklist.dto.response.SelectedChecklistResponse;
import com.bang_ggood.checklist.dto.response.UserChecklistPreviewResponse;
Copy link
Contributor

Choose a reason for hiding this comment

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

저희가 체크리스트 공유 기능이 있지 않고, 체크리스트에 유저 정보가 포함되지 않을 일이 없는데 user 명명을 쓴 이유가 궁금해요!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

예전에 사용하던거 그대로 사용했는데, User 빼도 좋을 것 같아서 이름 변경했습니다!

import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
Copy link
Contributor

Choose a reason for hiding this comment

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

작업량이 꽤나 많았겠네요 수고하셨습니다 👍

Copy link
Contributor

@shin-jisong shin-jisong left a comment

Choose a reason for hiding this comment

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

제가 마지막 approve네요! 머지하겠습니다 🍀

@shin-jisong shin-jisong merged commit 9896355 into dev-be Sep 21, 2024
2 checks passed
@shin-jisong shin-jisong deleted the feat/578-like-refactor branch September 21, 2024 06:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants