Skip to content

Conversation

@kjhh2605
Copy link
Contributor

#️⃣연관된 이슈

178

📝작업 내용

  • 팔로우 목록 조회 api
  • 프론트에서 삭제 카드 추천에 뜬다해서 쿼리문에 where isDeleted = false 추가했습니다

이번 PR에서 작업한 내용을 간략히 설명해주세요(이미지 첨부 가능)

스크린샷 (선택)

💬리뷰 요구사항(선택)

리뷰어가 특별히 봐주었으면 하는 부분이 있다면 작성해주세요

ex) 메서드 XXX의 이름을 더 잘 짓고 싶은데 혹시 좋은 명칭이 있을까요?

@kjhh2605 kjhh2605 linked an issue Aug 19, 2025 that may be closed by this pull request
3 tasks
Copy link

@gemini-code-assist gemini-code-assist bot left a 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

  1. 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.

Copy link

@gemini-code-assist gemini-code-assist bot left a 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);

Choose a reason for hiding this comment

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

critical

FOLLOWED 케이스의 로직에 오류가 있습니다. 주석에는 "해당 유저를 팔로우한 사람 목록"을 조회한다고 되어 있지만, 실제 호출되는 userRepository.searchAccountNotInFollow 메소드는 userId가 팔로우하지 않는 사용자 목록을 조회합니다. 이는 기능의 요구사항과 맞지 않는 심각한 버그입니다. userId를 팔로우하는 사용자(팔로워) 목록을 조회하는 새로운 레포지토리 메소드를 구현하고 호출해야 합니다. UserRepository에 제안한 변경사항을 참고하여 수정해주세요.

Comment on lines +45 to +58
@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);

Choose a reason for hiding this comment

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

critical

searchAccountNotInFollow 메소드는 이름 그대로 특정 유저가 '팔로우하지 않는' 유저를 검색합니다. 하지만 SearchServiceImplgetFollowList에서는 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);

Comment on lines +239 to +249
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);

Choose a reason for hiding this comment

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

high

페이징 처리를 위해 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);

Copy link
Member

@2anizirong 2anizirong left a comment

Choose a reason for hiding this comment

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

@kjhh2605 kjhh2605 force-pushed the feat/178-following-list branch from 4cf7f03 to 077cd96 Compare August 19, 2025 16:18
@kjhh2605 kjhh2605 merged commit f4bf890 into main Aug 19, 2025
3 checks passed
@2anizirong 2anizirong deleted the feat/178-following-list branch August 20, 2025 06:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feat] 해당 유저 팔로잉/팔로워 목록 조회 api

3 participants