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 @@ -32,7 +32,7 @@ public ApiResponse<SearchResponseDTO.GetCardListResponseDto> getAllUsersInSearch
return ApiResponse.onSuccess(result); // 리턴 부분 제대로 작동하는지 확인하기!
}

@Operation(summary = "검색 범위가 전체인 경우에서 계정 검색", description = "전체 - 계정 검색 api (nameId로 검색합니다.)")
@Operation(summary = "검색 범위가 전체인 경우에서 계정 검색", description = "전체 - 계정 검색 api (nickname, nameId으로 검색합니다.)")
@GetMapping("/all/account")
public ApiResponse<SearchResponseDTO.GetAccountListResponseDto> searchAccountInAll(
HttpServletRequest request,
Expand All @@ -44,7 +44,7 @@ public ApiResponse<SearchResponseDTO.GetAccountListResponseDto> searchAccountInA
return ApiResponse.onSuccess(result); // 리턴 부분 제대로 작동하는지 확인하기!
}

@Operation(summary = "검색범위가 유저가 팔로우한 사용자인 경우에서 계정 검색", description = "팔로우 - 계정 검색 api (nickname으로 검색)")
@Operation(summary = "검색범위가 유저가 팔로우한 사용자인 경우에서 계정 검색", description = "팔로우 - 계정 검색 api (nickname, nameId으로 검색합니다.)")
@GetMapping("/user-follow/account")
public ApiResponse<SearchResponseDTO.GetAccountListResponseDto> searchAccountInFollow(
HttpServletRequest request,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,25 +22,57 @@ public interface UserRepository extends JpaRepository<User,Long> {
User findUserById(Long id);

@Query("""
SELECT u FROM User u
WHERE (u.nameId LIKE %:query%)
AND (:cursor IS NULL OR u.id > :cursor)
ORDER BY u.id ASC
""")
SELECT u
FROM User u
WHERE (LOWER(u.nameId) LIKE LOWER(CONCAT(:query, '%'))
OR LOWER(u.nickname) LIKE LOWER(CONCAT(:query, '%')))
AND (:cursor IS NULL OR u.id > :cursor)
ORDER BY u.id ASC
""")
Slice<User> searchAccountInAll(@Param("query") String query,
@Param("cursor") Long cursor, Pageable pageable);
@Param("cursor") Long cursor,
Pageable pageable);

@Query("""
SELECT u
FROM User u
JOIN UserFollow uf ON u.id = uf.targetUser.id
WHERE uf.user.id = :loginUserId
AND (:cursor IS NULL OR u.id > :cursor)
AND u.nickname LIKE %:query%
AND (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);
@Param("cursor") Long cursor,
Pageable pageable,
@Param("loginUserId") Long userId);


// @Query("""
// SELECT u FROM User u
// WHERE (u.nameId LIKE %:query% OR u.nickname LIKE %:query%)
// AND (:cursor IS NULL OR u.id > :cursor)
// ORDER BY u.id ASC
//""")
// Slice<User> searchAccountInAll(@Param("query") String query,
// @Param("cursor") Long cursor, Pageable pageable);
//
//
// @Query("""
// SELECT u
// FROM User u
// JOIN UserFollow uf ON u.id = uf.targetUser.id
// WHERE uf.user.id = :loginUserId
// AND (:cursor IS NULL OR u.id > :cursor)
// AND (u.nameId LIKE %:query% OR u.nickname LIKE %: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
Expand Down
Loading