From c9e930aa93cd043fdd35878ecace0debaed3bedc Mon Sep 17 00:00:00 2001 From: peanut990 Date: Wed, 12 Feb 2025 00:52:56 +0900 Subject: [PATCH 1/2] =?UTF-8?q?fix:=20=EA=B2=8C=EC=8B=9C=EA=B8=80=20?= =?UTF-8?q?=EC=A0=84=EC=B2=B4=20=EC=A1=B0=ED=9A=8C=EC=84=9C=20=EC=B5=9C?= =?UTF-8?q?=EC=8B=A0=EC=88=9C=EC=9C=BC=EB=A1=9C=20=EB=B0=98=ED=99=98?= =?UTF-8?q?=ED=95=98=EB=8F=84=EB=A1=9D=20=EC=88=98=EC=A0=95=20(#87)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Refs: #87 --- .../java/com/starchive/springapp/post/service/PostService.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/BACK/spring-app/src/main/java/com/starchive/springapp/post/service/PostService.java b/BACK/spring-app/src/main/java/com/starchive/springapp/post/service/PostService.java index dfdb05c..75eac41 100644 --- a/BACK/spring-app/src/main/java/com/starchive/springapp/post/service/PostService.java +++ b/BACK/spring-app/src/main/java/com/starchive/springapp/post/service/PostService.java @@ -20,6 +20,7 @@ import org.springframework.data.domain.Page; import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Pageable; +import org.springframework.data.domain.Sort; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -55,7 +56,7 @@ public PostDto findOne(Long postId) { //todo: fetch join (양방향 연관관계) public PostListResponse findPosts(Long categoryId, Long hashTagId, int pageNum, int pageSize) { - Pageable pageable = PageRequest.of(pageNum, pageSize); + Pageable pageable = PageRequest.of(pageNum, pageSize, Sort.by("createAt").descending()); List categoryIds = null; if (categoryId != null) { Category category = categoryService.findOne(categoryId); From 350d28637d662fcad455a497da6cfa8ff4596127 Mon Sep 17 00:00:00 2001 From: peanut990 Date: Wed, 12 Feb 2025 01:02:55 +0900 Subject: [PATCH 2/2] =?UTF-8?q?fix:=20=EA=B2=8C=EC=8B=9C=EA=B8=80=20?= =?UTF-8?q?=EC=A0=84=EC=B2=B4=20=EC=A1=B0=ED=9A=8C=20=ED=85=8C=EC=8A=A4?= =?UTF-8?q?=ED=8A=B8=20=EC=BD=94=EB=93=9C=20=EC=88=98=EC=A0=95=20(#87)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Refs: #87 --- .../com/starchive/springapp/post/service/PostServiceTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BACK/spring-app/src/test/java/com/starchive/springapp/post/service/PostServiceTest.java b/BACK/spring-app/src/test/java/com/starchive/springapp/post/service/PostServiceTest.java index a9bf70e..e038c64 100644 --- a/BACK/spring-app/src/test/java/com/starchive/springapp/post/service/PostServiceTest.java +++ b/BACK/spring-app/src/test/java/com/starchive/springapp/post/service/PostServiceTest.java @@ -102,7 +102,7 @@ class PostServiceTest { //then assertThat(response.getPosts()).hasSize(2); assertThat(response.getPosts()).extracting("title").containsExactlyInAnyOrder("title1", "title2"); - assertThat(response.getPosts().get(0).getHashTags()).extracting("name").containsExactly("tag1"); + assertThat(response.getPosts().get(1).getHashTags()).extracting("name").containsExactly("tag1"); } @Test