Skip to content

Commit

Permalink
Merge pull request #158 from YogitTeam/feat/user-profile
Browse files Browse the repository at this point in the history
#8 feat : 애플 유저 탈퇴 - 연관된 user_profile, user_interest 엔티티 삭제
  • Loading branch information
shinhn authored Mar 24, 2023
2 parents 1f13984 + 7216d75 commit 478786c
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ public class DeleteUserReq {
Long userId;
String refreshToken;

String identityToken;
//String identityToken;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,17 +69,6 @@ public ApplicationResponse<UserProfileRes> getProfile(@ModelAttribute GetUserPro
return userService.getProfile(getUserProfileReq);
}

/**
* 유저 프로필 삭제
* @author 강신현
*/
@ApiOperation(value = "유저 프로필 삭제")
@ApiImplicitParam(name = "userId", required = true, dataTypeClass = Long.class, example = "0")
@PatchMapping("/{userId}")
public ApplicationResponse<Void> delProfile(@PathVariable Long userId){
return userService.delProfile(userId);
}

/**
* 유저 사진 조회
* @author 강신현
Expand Down
6 changes: 0 additions & 6 deletions server/src/main/java/com/yogit/server/user/entity/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@

public interface UserInterestRepository extends JpaRepository<UserInterest, Long> {
List<UserInterest> findAllByUserId(Long userId);

boolean existsByUserIdAndInterestId(Long userId, Long interestId);
void deleteAllByUserId(Long userId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public interface UserService {

ApplicationResponse<UserProfileRes> getProfile(GetUserProfileReq getUserProfileReq);

ApplicationResponse<Void> delProfile(Long userId);
ApplicationResponse<Void> delUser(Long userId);

ApplicationResponse<UserImagesRes> getUserImage(GetUserImageReq getUserImageReq);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,14 +209,14 @@ public ApplicationResponse<UserProfileRes> getProfile(GetUserProfileReq getUserP

@Override
@Transactional
public ApplicationResponse<Void> delProfile(Long userId){
public ApplicationResponse<Void> 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();
}
Expand Down

0 comments on commit 478786c

Please sign in to comment.