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();