-
Notifications
You must be signed in to change notification settings - Fork 2
[feat]팔로우 목록 조회 #180
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]팔로우 목록 조회 #180
Conversation
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.
Summary of Changes
Hello @kjhh2605, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
이 PR은 사용자 팔로우 목록을 조회하는 새로운 API를 추가하고, 프론트엔드에서 삭제된 카드가 추천 목록에 나타나는 버그를 수정합니다. 이를 통해 사용자들은 팔로워 및 팔로잉 목록을 검색하고 페이지네이션하여 볼 수 있으며, 시스템의 데이터 일관성이 향상됩니다.
Highlights
- 팔로우 목록 조회 API 추가: 특정 사용자의 팔로워 및 팔로잉 목록을 조회할 수 있는 /followList 엔드포인트가 SearchController에 추가되었습니다.
- 삭제된 카드 필터링 기능 개선: CardRepository의 쿼리에 WHERE c.isDeleted = false 조건이 추가되어, 삭제된 카드가 더 이상 추천 목록에 표시되지 않도록 수정되었습니다.
- 팔로우 상태를 포함한 계정 응답 DTO 정의: SearchResponseDTO에 GetAccountResponseDtoWithFollow 및 GetAccountListResponseDtoWithFollow가 추가되어, 팔로우 여부 정보를 포함한 계정 목록을 효율적으로 전달할 수 있게 되었습니다.
- 새로운 팔로우 상태 Enum 도입: FollowStatus enum이 추가되어 팔로우 관계의 상태(팔로잉, 팔로워)를 명확하게 정의하고 활용할 수 있게 되었습니다.
- 팔로우하지 않은 계정 검색 쿼리 추가: UserRepository에 searchAccountNotInFollow 쿼리가 추가되어, 특정 사용자가 팔로우하지 않은 계정을 검색하는 기능을 지원합니다.
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.
| Feature | Command | Description |
|---|---|---|
| Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
| Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
| Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
| Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
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.
Code Review
안녕하세요. 팔로우 목록 조회 기능 추가 PR 리뷰입니다.
전반적으로 기능 구현이 잘 이루어졌지만, 몇 가지 중요한 수정이 필요해 보입니다.
특히, 팔로워 목록을 조회하는 로직에 버그가 있어 수정이 필요합니다. 해당 유저를 팔로우하지 않는 유저를 조회하는 것으로 잘못 구현되어 있습니다.
또한, API 응답에서 페이징 처리가 된 리스트의 크기를 limit에 맞게 조절해주는 로직이 누락되었습니다.
자세한 내용은 각 파일의 코드 리뷰 코멘트를 참고해주세요.
| Slice<User> users = new SliceImpl<>(Collections.emptyList(), pageable, false); | ||
| switch(status){ | ||
| case FOLLOWED -> { // 해당 유저를 팔로우한 사람 목록 | ||
| users = userRepository.searchAccountNotInFollow(query, cursor, pageable, userId); |
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.
| @Query(""" | ||
| SELECT u | ||
| FROM User u | ||
| WHERE u.id NOT IN ( | ||
| SELECT uf.targetUser.id | ||
| FROM UserFollow uf | ||
| WHERE uf.user.id = :loginUserId | ||
| ) | ||
| AND (:cursor IS NULL OR u.id > :cursor) | ||
| AND u.nickname LIKE %:query% | ||
| ORDER BY u.id ASC | ||
| """) | ||
| Slice<User> searchAccountNotInFollow(@Param("query") String query, | ||
| @Param("cursor") Long cursor, Pageable pageable, @Param("loginUserId") Long userId); |
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.
이 searchAccountNotInFollow 메소드는 이름 그대로 특정 유저가 '팔로우하지 않는' 유저를 검색합니다. 하지만 SearchServiceImpl의 getFollowList에서는 FollowStatus.FOLLOWED (팔로워 목록 조회) 케이스에서 이 메소드를 사용하고 있습니다. 이는 기능 요구사항과 맞지 않습니다. 팔로워 목록을 조회하기 위한 쿼리로 수정하고, 혼동을 피하기 위해 메소드 이름도 searchFollowersByNickname 등으로 변경하는 것을 강력히 권장합니다.
@Query("""
SELECT u
FROM User u
JOIN UserFollow uf ON u.id = uf.user.id
WHERE uf.targetUser.id = :userId
AND (:cursor IS NULL OR u.id > :cursor)
AND u.nickname LIKE %:query%
ORDER BY u.id ASC
""")
Slice<User> searchFollowersByNickname(@Param("query") String query,
@Param("cursor") Long cursor, Pageable pageable, @Param("userId") Long userId);| List<SearchResponseDTO.GetAccountResponseDtoWithFollow> result = users.getContent().stream() | ||
| .map(user -> UserConverter.toAccountDtoWithFollow( | ||
| user, | ||
| alreadyFollowedIdSet.contains(user.getId())) | ||
| ).toList(); | ||
|
|
||
|
|
||
| boolean hasNext = users.hasNext(); | ||
| Long nextCursor = hasNext ? users.getContent().get(users.getContent().size() - 1).getId() : null; | ||
|
|
||
| return new SearchResponseDTO.GetAccountListResponseDtoWithFollow(result, nextCursor, result.size(), hasNext); |
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.
페이징 처리를 위해 limit + 1개의 데이터를 조회한 후, hasNext가 true일 때 응답 결과 리스트에서 마지막 아이템을 제거하여 limit 개수만큼만 반환해야 합니다. 현재 코드에서는 이 부분이 누락되어 클라이언트가 의도보다 많은 데이터를 받을 수 있습니다. 다른 API들처럼 리스트를 잘라내는 로직을 추가해야 합니다.
boolean hasNext = users.hasNext();
Long nextCursor = hasNext ? users.getContent().get(users.getContent().size() - 1).getId() : null;
List<User> userList = users.getContent();
if (hasNext) {
userList = userList.subList(0, limit);
}
List<SearchResponseDTO.GetAccountResponseDtoWithFollow> result = userList.stream()
.map(user -> UserConverter.toAccountDtoWithFollow(
user,
alreadyFollowedIdSet.contains(user.getId()))
).toList();
return new SearchResponseDTO.GetAccountListResponseDtoWithFollow(result, nextCursor, result.size(), hasNext);
src/main/java/EatPic/spring/domain/card/controller/SearchController.java
Show resolved
Hide resolved
2anizirong
left a comment
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.
굳
4cf7f03 to
077cd96
Compare
#️⃣연관된 이슈
📝작업 내용
스크린샷 (선택)
💬리뷰 요구사항(선택)