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 @@ -12,9 +12,10 @@
public interface CompleteRepository extends JpaRepository<Complete, Integer> {
List<Complete> findByTodo_TodoId(int todoId);

@Query("select c from Complete c where c.todo.goal.user.userId in :userIds order by c.createdAt desc")
Slice<Complete> findByFollowees(@Param("userIds") List<Integer> userIds, Pageable pageable);
@Query("select c from Complete c where c.todo.goal.user.userId in :userIds and c.completeStatus = :completeStatus order by c.createdAt desc")
Slice<Complete> findByFollowees(@Param("userIds") List<Integer> userIds, Pageable pageable, @Param("completeStatus") String completeStatus);

@Query("select c from Complete c where c.todo.goal.user.userId in :userIds and c.completeId < :completeId order by c.createdAt desc")
Slice<Complete> findByFolloweesAfterCompleteId(@Param("userIds")List<Integer> followeeIds, @Param("completeId") Integer completeId, Pageable pageable);
@Query("select c from Complete c where c.todo.goal.user.userId in :userIds and c.completeId < :completeId and c.completeStatus = :completeStatus order by c.createdAt desc")
Slice<Complete> findByFolloweesAfterCompleteId(@Param("userIds")List<Integer> followeeIds, @Param("completeId") Integer completeId, Pageable pageable,
@Param("completeStatus") String completeStatus);
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
@Transactional
public class FollowServiceImpl implements FollowService {

private static final String COMPLETE = "인증";

private final FollowRepository followRepository;
private final CompleteRepository completeRepository;
private final LikesRepository likesRepository;
Expand All @@ -45,9 +47,9 @@ public Slice<ReadFollowResponse> readFollows(int userId, ReadFollowRequest reque

Slice<Complete> completes;
if (Objects.isNull(request.lastCompleteId()) || request.lastCompleteId() <= 0) {
completes = completeRepository.findByFollowees(followeeIds, pageable);
completes = completeRepository.findByFollowees(followeeIds, pageable, COMPLETE);
} else {
completes = completeRepository.findByFolloweesAfterCompleteId(followeeIds, request.lastCompleteId(), pageable);
completes = completeRepository.findByFolloweesAfterCompleteId(followeeIds, request.lastCompleteId(), pageable, COMPLETE);
}

List<ReadFollowResponse> responses = completes.stream()
Expand Down
Loading