Skip to content

Commit

Permalink
[feat] #17 기본 게시글 조회 쿼리 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
RyuKwanKon committed Jan 3, 2024
1 parent a02c906 commit f0206e6
Showing 1 changed file with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,29 @@
public class PostQuerydslRepository {
private final JPAQueryFactory queryFactory;

public Page<PostSearchDto> findAllPosts(Pageable pageable) {
List<PostSearchDto> content = queryFactory
.select(new QPostSearchDto(
post.title,
post.content,
post.importantKeyType,
post.similarityKeyType,
post.endDate,
post.scrapList.size(),
postCheckList
))
.from(post)
.leftJoin(post.postCheckList, postCheckList)
.where(
validatePostDate()
)
.fetch();

JPAQuery<Post> countQuery = queryFactory
.selectFrom(post);
return PageableExecutionUtils.getPage(content, pageable, countQuery::fetchCount);
}

public Page<PostSearchDto> searchKeyPost(ImportantKeyType importantKeyType, Pageable pageable) {
List<PostSearchDto> content = queryFactory
.select(new QPostSearchDto(
Expand Down

0 comments on commit f0206e6

Please sign in to comment.