diff --git a/backend/baton/src/main/java/touch/baton/domain/runnerpost/repository/RunnerPostRepository.java b/backend/baton/src/main/java/touch/baton/domain/runnerpost/repository/RunnerPostRepository.java index 119d23fcb..33d21bd02 100644 --- a/backend/baton/src/main/java/touch/baton/domain/runnerpost/repository/RunnerPostRepository.java +++ b/backend/baton/src/main/java/touch/baton/domain/runnerpost/repository/RunnerPostRepository.java @@ -20,7 +20,7 @@ public interface RunnerPostRepository extends JpaRepository { """) Optional joinMemberByRunnerPostId(@Param("runnerPostId") final Long runnerPostId); - List findAllByOrderByCreatedAt(); + List findAllByOrderByCreatedAtDesc(); List findByRunnerId(Long runnerId); List readBySupporterId(Long supporterId); diff --git a/backend/baton/src/main/java/touch/baton/domain/runnerpost/service/RunnerPostService.java b/backend/baton/src/main/java/touch/baton/domain/runnerpost/service/RunnerPostService.java index f779b8ec9..bd0302ca9 100644 --- a/backend/baton/src/main/java/touch/baton/domain/runnerpost/service/RunnerPostService.java +++ b/backend/baton/src/main/java/touch/baton/domain/runnerpost/service/RunnerPostService.java @@ -198,7 +198,7 @@ public Long updateRunnerPost(final Long runnerPostId, final Runner runner, final } public List readAllRunnerPosts() { - return runnerPostRepository.findAllByOrderByCreatedAt(); + return runnerPostRepository.findAllByOrderByCreatedAtDesc(); } public List readRunnerPostsByRunnerId(final Long runnerId) { diff --git a/backend/baton/src/test/java/touch/baton/domain/runnerpost/repository/read/RunnerPostRepositoryReadTest.java b/backend/baton/src/test/java/touch/baton/domain/runnerpost/repository/read/RunnerPostRepositoryReadTest.java index f6adfc3ef..3ddda0699 100644 --- a/backend/baton/src/test/java/touch/baton/domain/runnerpost/repository/read/RunnerPostRepositoryReadTest.java +++ b/backend/baton/src/test/java/touch/baton/domain/runnerpost/repository/read/RunnerPostRepositoryReadTest.java @@ -151,13 +151,13 @@ void findAllByOrderByCreatedAt() { runnerPostRepository.save(nextRunnerPost); // when - final List actual = runnerPostRepository.findAllByOrderByCreatedAt(); + final List actual = runnerPostRepository.findAllByOrderByCreatedAtDesc(); // then assertSoftly(softly -> { softly.assertThat(actual).hasSize(2); - softly.assertThat(actual.get(0)).isEqualTo(previousRunnerPost); - softly.assertThat(actual.get(1)).isEqualTo(nextRunnerPost); + softly.assertThat(actual.get(0)).isEqualTo(nextRunnerPost); + softly.assertThat(actual.get(1)).isEqualTo(previousRunnerPost); }); } }