@Transactional(readOnly = true)
public Page<PostListDto> findBookmarkedPosts(Member member){
List<Bookmark> bookmarks = bookmarkRepository.findAllByMember(member);
List<PostListDto> dtoList = bookmarks.stream()
.map(bookmark -> new PostListDto(bookmark.getPosts()))
.collect(Collectors.toList());
return new PageImpl<>(dtoList);
}
Page 인터페이스를 구현한 PageImpl을 사용한다.
반응형
'BACK > SPRING' 카테고리의 다른 글
Spring Boot Project(2) - 프로젝트 세팅, MySQL 연동하기 (0) | 2023.01.24 |
---|---|
[Spring] 컴포넌트 스캔 / @Autowired (0) | 2023.01.17 |
[Spring] DI / IoC, 컨테이너, 의존성 주입 방법 (0) | 2023.01.09 |
[Spring] Spring AOP란 (1) | 2023.01.02 |
[Spring] MVC 동작 원리 (0) | 2022.12.25 |