From 730a3c694919948c4ae0dc61398be324ff50186b Mon Sep 17 00:00:00 2001 From: Amepistheo Date: Wed, 24 Jul 2024 18:54:17 +0900 Subject: [PATCH] =?UTF-8?q?:bug:=20Fix:=20=ED=99=88=20=EC=A0=95=EB=B3=B4?= =?UTF-8?q?=20=EC=A0=9C=EA=B3=B5=ED=95=A0=20=EB=95=8C=20postId=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80=20=EC=A0=9C=EA=B3=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/ticle/server/home/dto/response/PostSetsResponse.java | 2 ++ .../java/com/ticle/server/post/repository/PostRepository.java | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/ticle/server/home/dto/response/PostSetsResponse.java b/src/main/java/com/ticle/server/home/dto/response/PostSetsResponse.java index 4d8cb11..b766ed4 100644 --- a/src/main/java/com/ticle/server/home/dto/response/PostSetsResponse.java +++ b/src/main/java/com/ticle/server/home/dto/response/PostSetsResponse.java @@ -7,6 +7,7 @@ import java.util.Date; public record PostSetsResponse( + Long postId, String title, String imageUrl, Category category, @@ -16,6 +17,7 @@ public record PostSetsResponse( ) { public static PostSetsResponse from(Post post) { return new PostSetsResponse( + post.getPostId(), post.getTitle(), post.getImage().getImageUrl(), post.getCategory(), diff --git a/src/main/java/com/ticle/server/post/repository/PostRepository.java b/src/main/java/com/ticle/server/post/repository/PostRepository.java index ccb13c6..ee7dfcb 100644 --- a/src/main/java/com/ticle/server/post/repository/PostRepository.java +++ b/src/main/java/com/ticle/server/post/repository/PostRepository.java @@ -28,12 +28,12 @@ public interface PostRepository extends JpaRepository { "ORDER BY p.createdDate DESC LIMIT 1") Optional findTopPostByCategory(@Param("category") List category); - @Query("SELECT new com.ticle.server.home.dto.response.PostSetsResponse(p.title, p.image.imageUrl, p.category, p.author, p.createdDate) " + + @Query("SELECT new com.ticle.server.home.dto.response.PostSetsResponse(p.postId, p.title, p.image.imageUrl, p.category, p.author, p.createdDate) " + "FROM Post p " + "WHERE p.postId IN (:postIds)") List findSelectedPostInfoByIds(@Param("postIds") Set postIds); - @Query("SELECT new com.ticle.server.home.dto.response.PostSetsResponse(p.title, p.image.imageUrl, p.category, p.author, p.createdDate) " + + @Query("SELECT new com.ticle.server.home.dto.response.PostSetsResponse(p.postId, p.title, p.image.imageUrl, p.category, p.author, p.createdDate) " + "FROM Post p " + "ORDER BY p.scrapCount DESC LIMIT 3") List findTop3ByOrderByScrapCountDesc();