Skip to content

Commit

Permalink
Merge pull request #201 from gunsight1/feature_add_withdraw_member_hi…
Browse files Browse the repository at this point in the history
…story

feature :: 회원 탈퇴, 탈퇴 이력 추가
  • Loading branch information
gunsight1 authored Feb 28, 2024
2 parents 745304d + ea8643f commit d6f13d4
Show file tree
Hide file tree
Showing 6 changed files with 80 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ public enum MemberBusinessCode implements BusinessCode {
SUCCESS_REQUEST_RESET_PASSWORD_PAGE(HttpStatus.FOUND.value(), "BMC013", "비밀번호 초기화 토큰이 유효하므로 비밀번호 초기화 페이지로 접근합니다."),
SUCCESS_REQUEST_RESET_PASSWORD(HttpStatus.OK.value(), "BMC014", "비밀번호가 초기화되었습니다."),
SUCCESS_REQUEST_LOGIN_MEMBER_KAKAO(HttpStatus.OK.value(), "BMC015", "로그인 성공"),
SUCCESS_FIND_WASH_INFO_IN_MEMBER(HttpStatus.OK.value(), "BMC016","세차정보 조회 성공");
SUCCESS_REQUEST_SIGN_OUT_MEMBER(HttpStatus.OK.value(), "BMC016", "회원탈퇴 성공");
SUCCESS_FIND_WASH_INFO_IN_MEMBER(HttpStatus.OK.value(), "BMC017","세차정보 조회 성공");

private final int status;
private final String code;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import static com.kernel360.member.code.MemberBusinessCode.SUCCESS_REQUEST_JOIN_MEMBER_CREATED;
import static com.kernel360.member.code.MemberBusinessCode.SUCCESS_REQUEST_LOGIN_MEMBER;
import static com.kernel360.member.code.MemberBusinessCode.*;

@Slf4j
@RestController
Expand Down Expand Up @@ -117,4 +116,12 @@ public ResponseEntity<ApiResponse<MemberDto>> loginForKakao(@RequestHeader("Auth

return ApiResponse.toResponseEntity(SUCCESS_REQUEST_LOGIN_MEMBER, member);
}

@GetMapping("/signout")
public ResponseEntity<ApiResponse<MemberDto>> signOut(@RequestHeader("Authorization") String accessToken) {

memberService.signOut(accessToken);

return ApiResponse.toResponseEntity(SUCCESS_REQUEST_SIGN_OUT_MEMBER);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@
import com.kernel360.member.code.MemberErrorCode;
import com.kernel360.member.dto.*;
import com.kernel360.member.entity.Member;
import com.kernel360.member.entity.WithrawMember;
import com.kernel360.member.enumset.Age;
import com.kernel360.member.enumset.Gender;
import com.kernel360.member.repository.MemberRepository;
import com.kernel360.member.repository.WithrawMemberRepository;
import com.kernel360.utils.ConvertSHA256;
import com.kernel360.utils.JWT;
import com.kernel360.washinfo.entity.WashInfo;
Expand Down Expand Up @@ -38,6 +40,7 @@ public class MemberService {
private final CarInfoRepository carInfoRepository;
private final WashInfoRepository washInfoRepository;
private final KakaoRequest kakaoRequest;
private final WithrawMemberRepository withrawMemberRepository;

@Transactional
public void joinMember(MemberDto requestDto) {
Expand Down Expand Up @@ -245,6 +248,15 @@ public MemberDto loginForKakao(String accessToken) {
return MemberDto.fromKakao(memberDto, loginToken);
}

@Transactional
public void signOut(String accessToken) {
Member member = memberRepository.findOneById(jwt.ownerId(accessToken));

withrawMemberRepository.save(WithrawMember.of(member.getMemberNo(),member.getId(), member.getEmail(), null));

memberRepository.delete(member);
}

@Transactional(readOnly = true)
public boolean validatePassword(String password, String token) {
String id = JWT.ownerId(token);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package com.kernel360.member.entity;

import com.kernel360.base.BaseEntity;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Getter
@Entity
@Table(name = "withraw_member")
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class WithrawMember extends BaseEntity {

@Id
@Column(name = "member_no", nullable = false)
private Long memberNo;

@Column(name = "id", nullable = false, updatable = false)
private String id;

@Column(name = "email", nullable = false)
private String email;

@Column(name="ip")
private String ip;


public static WithrawMember of(Long memberNo, String id, String email, String ip) {

return new WithrawMember(memberNo, id, email, ip);
}

private WithrawMember(
Long memberNo,
String id,
String email,
String ip
) {
this.memberNo = memberNo;
this.id = id;
this.email = email;
this.ip = ip;
}

}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.kernel360.member.repository;

import com.kernel360.member.entity.WithrawMember;
import jakarta.persistence.Id;
import org.springframework.data.jpa.repository.JpaRepository;

public interface WithrawMemberRepository extends JpaRepository<WithrawMember, Id> {
}

0 comments on commit d6f13d4

Please sign in to comment.