Skip to content

Commit

Permalink
feat : 멤버 삭제 API 구현 (#64)
Browse files Browse the repository at this point in the history
  • Loading branch information
wjdwnsdnjs13 authored Jul 21, 2024
1 parent 88ec252 commit d71af4e
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import org.depromeet.spot.domain.member.Member;
import org.depromeet.spot.usecase.port.in.member.MemberUsecase;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
Expand Down Expand Up @@ -82,4 +83,18 @@ public String getAccessToken(
String idCode) {
return memberUsecase.getAccessToken(idCode);
}

@DeleteMapping("/{accessToken}")
@ResponseStatus(HttpStatus.OK)
@Operation(summary = "(개발용) Member 삭제 API")
public Boolean deleteMember(
@PathVariable("accessToken")
@Parameter(
name = "accessToken",
description = "sns accessToken",
required = true)
String accessToken) {
// TODO : (개발용) 유저 탈퇴 아님! 단순 유저 삭제만 진행함.
return memberUsecase.deleteMember(accessToken);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,6 @@ void updateProfile(
@Param("profileImage") String profileImage,
@Param("teamId") Long teamId,
@Param("nickname") String nickname);

void deleteByIdToken(String idToken);
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,9 @@ public Member findById(Long memberId) {
memberJpaRepository.findById(memberId).orElseThrow(MemberNotFoundException::new);
return entity.toDomain();
}

@Override
public void deleteByIdToken(String idToken) {
memberJpaRepository.deleteByIdToken(idToken);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,6 @@ public interface MemberUsecase {
Boolean duplicatedNickname(String nickname);

String getAccessToken(String idCode);

Boolean deleteMember(String accessToken);
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,6 @@ public interface MemberRepository {
Boolean existsByNickname(String nickname);

Member findById(Long memberId);

void deleteByIdToken(String idToken);
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
import java.util.Optional;

import org.depromeet.spot.common.exception.member.MemberException.MemberNicknameConflictException;
import org.depromeet.spot.common.exception.member.MemberException.MemberNotFoundException;
import org.depromeet.spot.domain.member.Member;
import org.depromeet.spot.usecase.port.in.member.MemberUsecase;
import org.depromeet.spot.usecase.port.out.member.MemberRepository;
import org.depromeet.spot.usecase.port.out.oauth.OauthRepository;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import lombok.RequiredArgsConstructor;

Expand Down Expand Up @@ -56,4 +58,17 @@ public Boolean duplicatedNickname(String nickname) {
public String getAccessToken(String idCode) {
return oauthRepository.getKakaoAccessToken(idCode);
}

@Transactional
@Override
public Boolean deleteMember(String accessToken) {
Member memberResult = oauthRepository.getLoginUserInfo(accessToken);
Optional<Member> existedMember = memberRepository.findByIdToken(memberResult.getIdToken());
// 멤버 없으면 오류 출력
if (existedMember.isEmpty()) {
throw new MemberNotFoundException();
}
memberRepository.deleteByIdToken(memberResult.getIdToken());
return Boolean.TRUE;
}
}

0 comments on commit d71af4e

Please sign in to comment.