File tree Expand file tree Collapse file tree
rentplace/src/main/java/kattsyn/dev/rentplace/services Expand file tree Collapse file tree Original file line number Diff line number Diff line change 55import kattsyn .dev .rentplace .dtos .users .UserCreateEditDTO ;
66import kattsyn .dev .rentplace .dtos .users .UserDTO ;
77import kattsyn .dev .rentplace .entities .User ;
8+ import org .springframework .security .core .Authentication ;
89import org .springframework .web .multipart .MultipartFile ;
910
1011import java .util .List ;
@@ -18,8 +19,6 @@ public interface UserService {
1819
1920 Optional <User > getUserOptionalByEmail (String email );
2021
21- boolean existsByEmail (String email );
22-
2322 UserDTO getUserDTOByEmail (String email );
2423
2524 UserDTO findById (Long id );
@@ -30,6 +29,8 @@ public interface UserService {
3029
3130 void deleteById (long id );
3231
32+ void deleteMe (Authentication authentication );
33+
3334 ImageDTO uploadImage (MultipartFile file , long id );
3435
3536 UserDTO updateUserById (long id , UserCreateEditDTO userCreateEditDTO );
Original file line number Diff line number Diff line change 1818import kattsyn .dev .rentplace .services .UserService ;
1919import kattsyn .dev .rentplace .utils .PathResolver ;
2020import lombok .RequiredArgsConstructor ;
21+ import org .springframework .security .core .Authentication ;
2122import org .springframework .stereotype .Service ;
2223import org .springframework .web .multipart .MultipartFile ;
2324
@@ -52,11 +53,6 @@ public Optional<User> getUserOptionalByEmail(String email) {
5253 return userRepository .findByEmail (email );
5354 }
5455
55- @ Override
56- public boolean existsByEmail (String email ) {
57- return userRepository .findByEmail (email ).isPresent ();
58- }
59-
6056 @ Override
6157 public UserDTO getUserDTOByEmail (String email ) {
6258 return userMapper .fromUser (userRepository .findByEmail (email )
@@ -99,6 +95,14 @@ public void deleteById(long id) {
9995 userRepository .delete (user );
10096 }
10197
98+ @ Override
99+ @ Transactional
100+ public void deleteMe (Authentication authentication ) {
101+ User user = getUserByEmail (authentication .getName ());
102+
103+ userRepository .delete (user );
104+ }
105+
102106 @ Transactional
103107 @ Override
104108 public ImageDTO uploadImage (MultipartFile file , long id ) {
You can’t perform that action at this time.
0 commit comments