Skip to content

Commit

Permalink
[feat] 유저 삭제 api 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryeolee committed Aug 26, 2024
1 parent 781e7a5 commit 5cdacaa
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ public BaseResponseDto<UserProfileResponse> selectUserProfile(@AuthenticationPri

@DeleteMapping()
public BaseResponseDto<?> deleteUser(@AuthenticationPrincipal CustomUser user) {
return userService.deleteUser(user.getUserId());
userService.deleteUser(user.getUserId());
return BaseResponseDto.of(SuccessCode.SUCCESS, null);
}


Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.modernfarmer.farmusspring.domain.user.service;

import com.modernfarmer.farmusspring.domain.farmclub.helper.FarmClubHelper;
import com.modernfarmer.farmusspring.domain.farmclub.helper.MissionPostHelper;
import com.modernfarmer.farmusspring.domain.myveggiegarden.entity.MyVeggie;
import com.modernfarmer.farmusspring.domain.myveggiegarden.helper.DiaryCommentHelper;
import com.modernfarmer.farmusspring.domain.myveggiegarden.helper.DiaryLikeHelper;
Expand Down Expand Up @@ -36,7 +38,9 @@ public class UserService {
private final UserHelper userHelper;
private final DiaryCommentHelper diaryCommentHelper;
private final DiaryLikeHelper diaryLikeHelper;
private MyVeggieHelper myVeggieHelper;
private final MyVeggieHelper myVeggieHelper;
private final FarmClubHelper farmClubHelper;
private final MissionPostHelper missionPostHelper;

@Transactional
public BaseResponseDto<UserProfileResponse> selectUserProfile(Long userId) {
Expand All @@ -51,7 +55,7 @@ public BaseResponseDto<UserProfileResponse> selectUserProfile(Long userId) {
}

@Transactional
public BaseResponseDto<Void> deleteUser(Long userId) {
public void deleteUser(Long userId) {
Optional<User> user = userRepository.findUser(userId);
// 유저 검증
verifyUser(user);
Expand All @@ -60,36 +64,24 @@ public BaseResponseDto<Void> deleteUser(Long userId) {
// 유저의 채소 엔티티 조회
List<MyVeggie> myVeggieList = myVeggieHelper.getMyVeggieUserId(userId);
// 내 채소 id를 통한 유저 팜클럽 삭제

farmClubHelper.deleteFarmClubDomain(myVeggieList);

// 채소 도메인 정보 삭제
// 유저 id를 통한 내 채소 삭제
myVeggieHelper.deleteMyVeggiesByUserId(userId);

// 유저 도메인 정보 삭제
// 1.1 유저 id를 통한 성장일기 좋아요 삭제
diaryLikeHelper.deleteLikesByUserId(userId);
diaryLikeHelper.deleteLikes(userId);
// 1.2 유저 id를 통한 성장일기 댓글 삭제
diaryCommentHelper.deleteCommentsByUserId(userId);
diaryCommentHelper.deleteComments(userId);
// 1.3 유저 id를 통한 인증글 좋아요 삭제
missionPostHelper.deleteMissionPostLikes(userId);
// 1.4 유저 id를 통한 인증글 댓글 삭제

missionPostHelper.deleteMissionPostComments(userId);

// 1.0 유저 도메인 삭제
userHelper.deleteUser(userId);












return null;
}


Expand Down

0 comments on commit 5cdacaa

Please sign in to comment.