|
1 | 1 | package kattsyn.dev.rentplace.services.impl; |
2 | 2 |
|
3 | 3 | import jakarta.transaction.Transactional; |
4 | | -import kattsyn.dev.rentplace.dtos.ImageDTO; |
5 | | -import kattsyn.dev.rentplace.dtos.UserCreateEditDTO; |
6 | | -import kattsyn.dev.rentplace.dtos.UserDTO; |
| 4 | +import kattsyn.dev.rentplace.dtos.*; |
7 | 5 | import kattsyn.dev.rentplace.entities.Image; |
8 | 6 | import kattsyn.dev.rentplace.entities.User; |
9 | 7 | import kattsyn.dev.rentplace.enums.ImageType; |
@@ -44,6 +42,11 @@ public User getUserByEmail(String email) { |
44 | 42 | ); |
45 | 43 | } |
46 | 44 |
|
| 45 | + @Override |
| 46 | + public boolean existsByEmail(String email) { |
| 47 | + return userRepository.existsByEmail(email); |
| 48 | + } |
| 49 | + |
47 | 50 | @Override |
48 | 51 | public UserDTO getUserDTOByEmail(String email) { |
49 | 52 | return userMapper.fromUser(userRepository.findByEmail(email) |
@@ -150,6 +153,16 @@ public boolean allowedToEditUser(long id, String email) { |
150 | 153 | throw new ForbiddenException(String.format("FORBIDDEN. You are not allowed to edit user email: %s.", email)); |
151 | 154 | } |
152 | 155 |
|
| 156 | + |
| 157 | + @Override |
| 158 | + public User createUserWithRegisterRequest(RegisterRequest registerRequest) { |
| 159 | + User user = userMapper.fromRegisterRequest(registerRequest); |
| 160 | + user.setRegistrationDate(LocalDate.now()); |
| 161 | + user.setRole(Role.ROLE_USER); |
| 162 | + |
| 163 | + return userRepository.save(user); |
| 164 | + } |
| 165 | + |
153 | 166 | private UserDTO uploadImage(MultipartFile file, User user) { |
154 | 167 | String path = PathResolver.resolvePath(ImageType.USER, user.getUserId()); |
155 | 168 |
|
|
0 commit comments