Skip to content

Commit

Permalink
feat: 회원 탈퇴 로직 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
kjungw1025 committed Dec 16, 2023
1 parent 19ec3fa commit 6f1857f
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,13 @@ public ResponseMemberInfoDto getMemberInfo(AppAuthentication auth) {
return memberService.getMemberInfo(auth.getUserId());
}

// /**
// * 회원탈퇴
// * <p>회원은 바로 삭제되지 않고, 일정 기간 뒤에 삭제됩니다. 삭제시에도 개인 정보만 삭제됩니다.</p>
// */
// @DeleteMapping
// public void withdraw(AppAuthentication auth) {
// memberWithdrawService.withdraw(auth.getUserId());
// }
/**
* 회원탈퇴
* <p>회원은 바로 삭제되지 않고(비활성화로 전환), 일정 기간 뒤에 삭제됩니다.</p>
*/
@DeleteMapping
@MemberAuth
public void withdraw(AppAuthentication auth) {
memberWithdrawService.withdraw(auth.getUserId());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,7 @@ public interface MemberRepository extends JpaRepository<Member, Long> , JpaSpeci

@Query("select m from Member m where m.status = 'ACTIVE' and m.name = :name")
Optional<Member> findByName(String name);

@Query("select m from Member m where m.status = 'INACTIVE' and m.phone = :phone")
Optional<Member> findByInactiveByPhone(String phone);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.taba.nimonaemo.member.service;

import com.taba.nimonaemo.member.exception.UserNotFoundException;
import com.taba.nimonaemo.member.model.MemberStatus;
import com.taba.nimonaemo.member.model.entity.Member;
import com.taba.nimonaemo.member.repository.MemberRepository;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@RequiredArgsConstructor
@Transactional(readOnly = true)
public class MemberWithdrawService {
private final MemberRepository memberRepository;

@Transactional
public void withdraw(Long userId) {
Member member = memberRepository.findById(userId).orElseThrow(UserNotFoundException::new);
member.changeStatus(MemberStatus.INACTIVE);
}
}

0 comments on commit 6f1857f

Please sign in to comment.