1
|
|
|
package com.osomapps.pt.admin.exercise; |
2
|
|
|
|
3
|
|
|
import com.osomapps.pt.dictionary.DictionaryName; |
4
|
|
|
import com.osomapps.pt.dictionary.DictionaryService; |
5
|
|
|
import com.osomapps.pt.exercises.ExerciseEquipmentType; |
6
|
|
|
import java.util.List; |
7
|
|
|
import java.util.stream.Collectors; |
8
|
|
|
import org.springframework.stereotype.Service; |
9
|
|
|
|
10
|
|
|
@Service |
11
|
|
|
class AdminExerciseEquipmentTypeService { |
12
|
|
|
|
13
|
|
|
private final ExerciseEquipmentTypeRepository exerciseEquipmentTypeRepository; |
14
|
|
|
private final DictionaryService dictionaryService; |
15
|
|
|
|
16
|
|
|
AdminExerciseEquipmentTypeService( |
17
|
|
|
ExerciseEquipmentTypeRepository exerciseEquipmentTypeRepository, |
18
|
|
|
DictionaryService dictionaryService) { |
19
|
|
|
this.exerciseEquipmentTypeRepository = exerciseEquipmentTypeRepository; |
20
|
|
|
this.dictionaryService = dictionaryService; |
21
|
|
|
} |
22
|
|
|
|
23
|
|
|
List<ExerciseEquipmentTypeResponseDTO> findAll() { |
24
|
|
|
return exerciseEquipmentTypeRepository.findAll().stream() |
25
|
|
|
.map(equipmentType -> exerciseEquipmentTypeToDto(equipmentType)) |
26
|
|
|
.collect(Collectors.toList()); |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
private ExerciseEquipmentTypeResponseDTO exerciseEquipmentTypeToDto( |
30
|
|
|
ExerciseEquipmentType equipmentType) { |
31
|
|
|
final String exerciseEquipmentTypeEnName = |
32
|
|
|
dictionaryService.getEnValue( |
33
|
|
|
DictionaryName.exercise_equipment_type_name, |
34
|
|
|
equipmentType.getDExerciseEquipmentTypeName(), |
35
|
|
|
""); |
36
|
|
|
final String exerciseEquipmentTypeNoName = |
37
|
|
|
dictionaryService.getNoValue( |
38
|
|
|
DictionaryName.exercise_equipment_type_name, |
39
|
|
|
equipmentType.getDExerciseEquipmentTypeName(), |
40
|
|
|
exerciseEquipmentTypeEnName); |
41
|
|
|
return ExerciseEquipmentTypeResponseDTO.builder() |
42
|
|
|
.id(equipmentType.getId()) |
43
|
|
|
.nameEn(exerciseEquipmentTypeEnName) |
44
|
|
|
.nameNo(exerciseEquipmentTypeNoName) |
45
|
|
|
.build(); |
46
|
|
|
} |
47
|
|
|
} |
48
|
|
|
|