|
2 | 2 |
|
3 | 3 | import java.util.UUID;
|
4 | 4 |
|
| 5 | +import com.ajou.hertz.domain.instrument.service.InstrumentCommandService; |
| 6 | +import com.ajou.hertz.domain.instrument.service.InstrumentQueryService; |
| 7 | +import com.ajou.hertz.domain.practice_room.entity.PracticeRoom; |
| 8 | +import com.ajou.hertz.domain.practice_room.service.PracticeRoomCommandService; |
| 9 | +import com.ajou.hertz.domain.practice_room.service.PracticeRoomQueryService; |
5 | 10 | import com.ajou.hertz.domain.user.controller.UpdatePasswordWithoutAuthenticationRequest;
|
| 11 | +import com.ajou.hertz.domain.user.exception.UserDeletionPermissionDeniedException; |
6 | 12 | import org.springframework.security.crypto.password.PasswordEncoder;
|
7 | 13 | import org.springframework.stereotype.Service;
|
8 | 14 | import org.springframework.transaction.annotation.Transactional;
|
|
28 | 34 | public class UserCommandService {
|
29 | 35 |
|
30 | 36 | private final UserQueryService userQueryService;
|
| 37 | + private final UserProfileImageCommandService userProfileImageCommandService; |
| 38 | + private final PracticeRoomCommandService practiceRoomCommandService; |
31 | 39 | private final UserRepository userRepository;
|
32 | 40 | private final PasswordEncoder passwordEncoder;
|
33 | 41 | private final HertzProperties hertzProperties;
|
34 |
| - private final UserProfileImageCommandService userProfileImageCommandService; |
| 42 | + private final InstrumentCommandService instrumentCommandService; |
35 | 43 |
|
36 | 44 | /**
|
37 | 45 | * 새로운 회원을 등록한다.
|
@@ -187,4 +195,19 @@ public UserDto updatePassword(UpdatePasswordWithoutAuthenticationRequest updateP
|
187 | 195 | user.changePassword(passwordEncoder.encode(updatePasswordRequest.getPassword()));
|
188 | 196 | return UserDto.from(user);
|
189 | 197 | }
|
| 198 | + |
| 199 | + public void deleteUser(Long requesterId, Long userId) { |
| 200 | + if (!requesterId.equals(userId)) { |
| 201 | + throw new UserDeletionPermissionDeniedException(); |
| 202 | + } |
| 203 | + |
| 204 | + instrumentCommandService.removeSellerFromInstruments(userId); |
| 205 | + practiceRoomCommandService.removeSellerFromPracticeRooms(userId); |
| 206 | + // TODO: 공연장(ConcertHall)에서 유저 제거 (연관관계 끊기) |
| 207 | + |
| 208 | + userRepository.deleteById(userId); |
| 209 | + userProfileImageCommandService.deleteImagesByUserId(userId); |
| 210 | + |
| 211 | + // TODO: 유저 탈퇴 이력 저장 |
| 212 | + } |
190 | 213 | }
|
0 commit comments