diff --git a/server/src/main/java/com/yogit/server/applelogin/model/DeleteUserReq.java b/server/src/main/java/com/yogit/server/applelogin/model/DeleteUserReq.java index b010d05..2ae5ead 100644 --- a/server/src/main/java/com/yogit/server/applelogin/model/DeleteUserReq.java +++ b/server/src/main/java/com/yogit/server/applelogin/model/DeleteUserReq.java @@ -11,5 +11,5 @@ public class DeleteUserReq { Long userId; String refreshToken; - String identityToken; + //String identityToken; } diff --git a/server/src/main/java/com/yogit/server/applelogin/service/AppleServiceImpl.java b/server/src/main/java/com/yogit/server/applelogin/service/AppleServiceImpl.java index f308f93..9fb6913 100644 --- a/server/src/main/java/com/yogit/server/applelogin/service/AppleServiceImpl.java +++ b/server/src/main/java/com/yogit/server/applelogin/service/AppleServiceImpl.java @@ -169,10 +169,6 @@ public void deleteUser(DeleteUserReq deleteUserReq) { // 유저 정보 삭제 및 유저 상태 변경 (DELETE) tokenService.validateRefreshToken(deleteUserReq.getUserId(), deleteUserReq.getRefreshToken()); - // 유저 entity - 개인 정보 삭제 - User user = userRepository.findByUserId(deleteUserReq.getUserId()).orElseThrow(() -> new NotFoundUserException()); - user.deleteUser(); - // 유저 연관 entity - 정보 삭제 - + userService.delUser(deleteUserReq.getUserId()); } } diff --git a/server/src/main/java/com/yogit/server/user/controller/UserController.java b/server/src/main/java/com/yogit/server/user/controller/UserController.java index 99a2246..447c9c6 100644 --- a/server/src/main/java/com/yogit/server/user/controller/UserController.java +++ b/server/src/main/java/com/yogit/server/user/controller/UserController.java @@ -69,17 +69,6 @@ public ApplicationResponse getProfile(@ModelAttribute GetUserPro return userService.getProfile(getUserProfileReq); } - /** - * 유저 프로필 삭제 - * @author 강신현 - */ - @ApiOperation(value = "유저 프로필 삭제") - @ApiImplicitParam(name = "userId", required = true, dataTypeClass = Long.class, example = "0") - @PatchMapping("/{userId}") - public ApplicationResponse delProfile(@PathVariable Long userId){ - return userService.delProfile(userId); - } - /** * 유저 사진 조회 * @author 강신현 diff --git a/server/src/main/java/com/yogit/server/user/entity/User.java b/server/src/main/java/com/yogit/server/user/entity/User.java index e70827b..f9434f3 100644 --- a/server/src/main/java/com/yogit/server/user/entity/User.java +++ b/server/src/main/java/com/yogit/server/user/entity/User.java @@ -127,12 +127,6 @@ public void changeUserInfo(String userName, Integer userAge, String gender, Stri if(nationality != null) this.nationality = nationality; } - public void delUser(){ - this.name = null; - this.profileImg = null; - this.userStatus = UserStatus.DELETE; - } - public void addImage(UserImage userImage) { this.userImages.add(userImage); } diff --git a/server/src/main/java/com/yogit/server/user/repository/UserInterestRepository.java b/server/src/main/java/com/yogit/server/user/repository/UserInterestRepository.java index e76ae69..d9dfbd4 100644 --- a/server/src/main/java/com/yogit/server/user/repository/UserInterestRepository.java +++ b/server/src/main/java/com/yogit/server/user/repository/UserInterestRepository.java @@ -7,6 +7,6 @@ public interface UserInterestRepository extends JpaRepository { List findAllByUserId(Long userId); - boolean existsByUserIdAndInterestId(Long userId, Long interestId); + void deleteAllByUserId(Long userId); } diff --git a/server/src/main/java/com/yogit/server/user/service/UserService.java b/server/src/main/java/com/yogit/server/user/service/UserService.java index 19a90f6..af7c147 100644 --- a/server/src/main/java/com/yogit/server/user/service/UserService.java +++ b/server/src/main/java/com/yogit/server/user/service/UserService.java @@ -11,7 +11,7 @@ public interface UserService { ApplicationResponse getProfile(GetUserProfileReq getUserProfileReq); - ApplicationResponse delProfile(Long userId); + ApplicationResponse delUser(Long userId); ApplicationResponse getUserImage(GetUserImageReq getUserImageReq); diff --git a/server/src/main/java/com/yogit/server/user/service/UserServiceImpl.java b/server/src/main/java/com/yogit/server/user/service/UserServiceImpl.java index 0c7f539..eaa1a7c 100644 --- a/server/src/main/java/com/yogit/server/user/service/UserServiceImpl.java +++ b/server/src/main/java/com/yogit/server/user/service/UserServiceImpl.java @@ -209,14 +209,14 @@ public ApplicationResponse getProfile(GetUserProfileReq getUserP @Override @Transactional - public ApplicationResponse delProfile(Long userId){ + public ApplicationResponse delUser(Long userId){ User user = userRepository.findByUserId(userId).orElseThrow(NotFoundUserException::new); + user.deleteUser(); - // 유저 탈퇴시 이름, 대표 사진 null 처리 - user.delUser(); - - // image 엔티티 삭제 + // user_image 엔티티 삭제 userImageRepository.deleteAllByUserId(user.getId()); + // user_interest 엔티티 삭제 + userInterestRepository.deleteAllByUserId(user.getId()); return ApplicationResponse.ok(); }