-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEncyclopediaService.java
More file actions
34 lines (25 loc) · 1.02 KB
/
EncyclopediaService.java
File metadata and controls
34 lines (25 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package springboot.study.service;
import org.springframework.stereotype.Service;
import springboot.study.dto.EncyclopediaDto;
import springboot.study.repository.EncyclopediaRepository;
import java.util.List;
import java.util.stream.Collectors;
@Service
public class EncyclopediaService {
private final EncyclopediaRepository encyclopediaRepository;
public EncyclopediaService(EncyclopediaRepository encyclopediaRepository) {
this.encyclopediaRepository = encyclopediaRepository;
}
public List<EncyclopediaDto> findByQuery(String query) {
return encyclopediaRepository.findByQuery(query).getItems().stream()
.map(e -> EncyclopediaDto.builder()
.title(e.getTitle())
.link(e.getLink())
.display(e.getDisplay())
.start(e.getStart())
.total(e.getTotal())
.display(e.getDisplay())
.build())
.collect(Collectors.toList());
}
}