Total Complexity | 4 |
Total Lines | 24 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | package com.osomapps.pt.admin.exercise; |
||
9 | @Service |
||
10 | class AdminExerciseOutputService { |
||
11 | |||
12 | private final ExerciseOutputRepository exerciseOutputRepository; |
||
13 | |||
14 | AdminExerciseOutputService(ExerciseOutputRepository exerciseOutputRepository) { |
||
15 | this.exerciseOutputRepository = exerciseOutputRepository; |
||
16 | } |
||
17 | |||
18 | List<ExerciseOutputResponseDTO> findAll() { |
||
19 | return exerciseOutputRepository.findAll(sortByIdAsc()).stream() |
||
20 | .map(AdminExerciseOutputService::exerciseOutputToDto) |
||
21 | .collect(Collectors.toList()); |
||
22 | } |
||
23 | |||
24 | private Sort sortByIdAsc() { |
||
25 | return Sort.by(Sort.Direction.ASC, "id"); |
||
26 | } |
||
27 | |||
28 | private static ExerciseOutputResponseDTO exerciseOutputToDto(ExerciseOutput output) { |
||
29 | return ExerciseOutputResponseDTO.builder() |
||
30 | .id(output.getId()) |
||
31 | .name(output.getName()) |
||
32 | .build(); |
||
33 | } |
||
35 |