id
,Β title
,Β viewCount
QueryDSL
μΒ Projections.constructor
λ₯Ό μ¬μ©νμ¬ DTOλ‘ λ°λ‘ λ§€νPageable
Β κ°μ²΄λ₯Ό ν΅ν΄ νμ΄μ§ μ²λ¦¬Projections.constructor
)μ 체 κ²μκΈ μν°ν°λ₯Ό μ‘°ννλ©΄ λΆνμν μ°κ΄ λ°μ΄ν°κΉμ§ λ‘λ©λ μ μμ
β μ±λ₯ μ ν, κ³Όλν λ©λͺ¨λ¦¬ μ¬μ©
νλ‘ νΈμ λ ΈμΆν λ°μ΄ν°λ§ μ‘°ννμ¬Β νΈλν½ μ κ° λ° μλ΅ μλ ν₯μμ λͺ©ν
@Transactional(readOnly = true)
public List<PostResponseDto> getAllPosts(Pageable pageable) {
Page<PostListPageDto> postList = postRepository.getPostList(pageable);
return postList.stream().map(post -> new PostResponseDto(post)).toList();
}