Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,14 @@ public ApiResponse<SearchResponseDTO.GetCardListResponseDto> getCardsByHashtag(
return ApiResponse.onSuccess(result);
}

@Operation(summary = "해당 유저 팔로우 목록 조회", description = "팔로우 - 해시태그 검색 api")
@Operation(summary = "해당 유저 팔로잉,팔로워 검색", description = "FOLLOWING은 유저(userId)가 팔로우 중인 목록을, FOLLOWED는 유저를 팔로우하는 목록을 반환합니다." +
"<br> query가 null일 경우 임의의 팔로잉/팔로워 목록을 반환합니다")
@GetMapping("/followList")
public ApiResponse<SearchResponseDTO.GetAccountListResponseDtoWithFollow> searchFollowList(
HttpServletRequest request,
@RequestParam(value = "follow status")FollowStatus status,
@RequestParam(value = "userId")Long userId,
@RequestParam(value = "query") String query,
@RequestParam(value = "query", required = false) String query,
@RequestParam(value = "limit", required = false, defaultValue = "10") int limit,
@RequestParam(value = "cursor", required = false) Long cursor
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ public SearchResponseDTO.GetAccountListResponseDtoWithFollow getFollowList(HttpS
Slice<User> users = new SliceImpl<>(Collections.emptyList(), pageable, false);
switch(status){
case FOLLOWED -> { // 해당 유저를 팔로우한 사람 목록
users = userRepository.searchAccountNotInFollow(query, cursor, pageable, userId);
users = userRepository.searchAccountInFollower(query, cursor, pageable, userId);
}
case FOLLOWING -> { // 해당 유저가 팔로우한 사람 목록
users = userRepository.searchAccountInFollow(query, cursor, pageable, userId);
Expand All @@ -234,12 +234,10 @@ public SearchResponseDTO.GetAccountListResponseDtoWithFollow getFollowList(HttpS
// 내가 팔로우한 유저 목록
Set<Long> alreadyFollowedIdSet = new HashSet<>(userFollowRepository.findFollowingUserIds(me.getId()));



List<SearchResponseDTO.GetAccountResponseDtoWithFollow> result = users.getContent().stream()
.map(user -> UserConverter.toAccountDtoWithFollow(
user,
alreadyFollowedIdSet.contains(user.getId()))
alreadyFollowedIdSet.contains(user.getId())) // 내 기준 팔로우 여부 표시
).toList();


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,32 @@ Slice<User> searchAccountInAll(@Param("query") String query,
JOIN UserFollow uf ON u.id = uf.targetUser.id
WHERE uf.user.id = :loginUserId
AND (:cursor IS NULL OR u.id > :cursor)
AND (LOWER(u.nameId) LIKE LOWER(CONCAT(:query, '%'))
OR LOWER(u.nickname) LIKE LOWER(CONCAT(:query, '%')))
AND (:query IS NULL OR
(LOWER(u.nameId) LIKE LOWER(CONCAT(:query, '%'))
OR LOWER(u.nickname) LIKE LOWER(CONCAT(:query, '%'))))
ORDER BY u.id ASC
""")
Slice<User> searchAccountInFollow(@Param("query") String query,
@Param("cursor") Long cursor,
Pageable pageable,
@Param("loginUserId") Long userId);

@Query("""
SELECT u
FROM User u
JOIN UserFollow uf ON u.id = uf.user.id
WHERE uf.targetUser.id = :loginUserId
AND (:cursor IS NULL OR u.id > :cursor)
AND (:query IS NULL OR
(LOWER(u.nameId) LIKE LOWER(CONCAT(:query, '%'))
OR LOWER(u.nickname) LIKE LOWER(CONCAT(:query, '%'))))
ORDER BY u.id ASC
""")
Slice<User> searchAccountInFollower(@Param("query") String query,
@Param("cursor") Long cursor,
Pageable pageable,
@Param("loginUserId") Long userId);


// @Query("""
// SELECT u FROM User u
Expand All @@ -74,19 +91,5 @@ Slice<User> searchAccountInFollow(@Param("query") String query,
// @Param("loginUserId") Long userId);


@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);

}
Loading