Skip to content

Commit

Permalink
🐛 Fix: 홈 정보 제공할 때 postId 추가 제공
Browse files Browse the repository at this point in the history
  • Loading branch information
Amepistheo committed Jul 24, 2024
1 parent cfdf38b commit 730a3c6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import java.util.Date;

public record PostSetsResponse(
Long postId,
String title,
String imageUrl,
Category category,
Expand All @@ -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(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ public interface PostRepository extends JpaRepository<Post, Long> {
"ORDER BY p.createdDate DESC LIMIT 1")
Optional<Post> findTopPostByCategory(@Param("category") List<Category> 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<PostSetsResponse> findSelectedPostInfoByIds(@Param("postIds") Set<Long> 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<PostSetsResponse> findTop3ByOrderByScrapCountDesc();
Expand Down

0 comments on commit 730a3c6

Please sign in to comment.