| Total Complexity | 3 |
| Total Lines | 30 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | package com.osomapps.pt.admin.user; |
||
| 9 | @Service |
||
| 10 | class AdminUserTypeService { |
||
| 11 | |||
| 12 | private final InUserTypeRepository inUserTypeRepository; |
||
| 13 | private final DictionaryService dictionaryService; |
||
| 14 | |||
| 15 | AdminUserTypeService( |
||
| 16 | InUserTypeRepository inUserTypeRepository, DictionaryService dictionaryService) { |
||
| 17 | this.inUserTypeRepository = inUserTypeRepository; |
||
| 18 | this.dictionaryService = dictionaryService; |
||
| 19 | } |
||
| 20 | |||
| 21 | List<UserTypeResponseDTO> findAll() { |
||
| 22 | return inUserTypeRepository.findAll().stream() |
||
| 23 | .map(userType -> userTypeToDto(userType)) |
||
| 24 | .collect(Collectors.toList()); |
||
| 25 | } |
||
| 26 | |||
| 27 | private UserTypeResponseDTO userTypeToDto(InUserType inUserType) { |
||
| 28 | final String userTypeEnName = |
||
| 29 | dictionaryService.getEnValue( |
||
| 30 | DictionaryName.user_type, inUserType.getD_user_type(), ""); |
||
| 31 | final String userTypeNoName = |
||
| 32 | dictionaryService.getNoValue( |
||
| 33 | DictionaryName.user_type, inUserType.getD_user_type(), ""); |
||
| 34 | return UserTypeResponseDTO.builder() |
||
| 35 | .id(inUserType.getId()) |
||
| 36 | .nameEn(userTypeEnName) |
||
| 37 | .nameNo(userTypeNoName) |
||
| 38 | .build(); |
||
| 39 | } |
||
| 41 |