-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: 회원 탈퇴 API 구현 * chore: 코드 수정 * test: 테스트코드 추가 * chore: swagger 주석 추가 * chore: 요청 필드명 변경 * chore: 주석 추가
- Loading branch information
Showing
16 changed files
with
150 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
src/main/java/com/nexters/goalpanzi/application/mission/handler/DeleteMemberEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package com.nexters.goalpanzi.application.mission.handler; | ||
|
||
public record DeleteMemberEvent( | ||
Long memberId | ||
) { | ||
} |
25 changes: 25 additions & 0 deletions
25
...ain/java/com/nexters/goalpanzi/application/mission/handler/MissionMemberEventHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package com.nexters.goalpanzi.application.mission.handler; | ||
|
||
import com.nexters.goalpanzi.domain.common.BaseEntity; | ||
import com.nexters.goalpanzi.domain.mission.repository.MissionMemberRepository; | ||
import com.nexters.goalpanzi.domain.mission.repository.MissionVerificationRepository; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Component; | ||
import org.springframework.transaction.event.TransactionPhase; | ||
import org.springframework.transaction.event.TransactionalEventListener; | ||
|
||
@Component | ||
@RequiredArgsConstructor | ||
public class MissionMemberEventHandler { | ||
|
||
private final MissionMemberRepository missionMemberRepository; | ||
private final MissionVerificationRepository missionVerificationRepository; | ||
|
||
@TransactionalEventListener(phase = TransactionPhase.BEFORE_COMMIT) | ||
void handelDeleteMemberEvent(final DeleteMemberEvent event) { | ||
missionMemberRepository.findAllByMemberId(event.memberId()) | ||
.forEach(BaseEntity::delete); | ||
missionVerificationRepository.findByMemberId(event.memberId()) | ||
.forEach(BaseEntity::delete); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 10 additions & 1 deletion
11
src/main/java/com/nexters/goalpanzi/domain/member/Member.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/main/java/com/nexters/goalpanzi/presentation/mission/dto/JoinMissionRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
package com.nexters.goalpanzi.presentation.mission.dto; | ||
|
||
public record JoinMissionRequest( | ||
String missionCode | ||
String invitationCode | ||
) { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
src/test/java/com/nexters/goalpanzi/acceptance/MemberAcceptanceTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package com.nexters.goalpanzi.acceptance; | ||
|
||
import com.nexters.goalpanzi.application.auth.dto.request.GoogleLoginCommand; | ||
import com.nexters.goalpanzi.application.auth.dto.response.LoginResponse; | ||
import com.nexters.goalpanzi.application.mission.dto.response.MissionDetailResponse; | ||
import com.nexters.goalpanzi.common.jwt.JwtProvider; | ||
import com.nexters.goalpanzi.domain.member.repository.MemberRepository; | ||
import com.nexters.goalpanzi.domain.mission.repository.MissionMemberRepository; | ||
import io.restassured.RestAssured; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.http.HttpHeaders; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.MediaType; | ||
|
||
import static com.nexters.goalpanzi.acceptance.AcceptanceStep.*; | ||
import static com.nexters.goalpanzi.fixture.MemberFixture.EMAIL; | ||
import static com.nexters.goalpanzi.fixture.MemberFixture.ID_TOKEN; | ||
import static com.nexters.goalpanzi.fixture.TokenFixture.BEARER; | ||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
public class MemberAcceptanceTest extends AcceptanceTest { | ||
|
||
@Autowired | ||
private MemberRepository memberRepository; | ||
|
||
@Test | ||
void 회원이_탈퇴한다() { | ||
LoginResponse login = 구글_로그인(new GoogleLoginCommand(ID_TOKEN, EMAIL)).as(LoginResponse.class); | ||
MissionDetailResponse mission = 미션_생성(login.accessToken()).as(MissionDetailResponse.class); | ||
미션_참여(mission.invitationCode(), login.accessToken()); | ||
|
||
RestAssured.given().log().all() | ||
.contentType(MediaType.APPLICATION_JSON_VALUE) | ||
.header(HttpHeaders.AUTHORIZATION, BEARER + login.accessToken()) | ||
.when().delete("/api/member") | ||
.then().log().all() | ||
.statusCode(HttpStatus.NO_CONTENT.value()); | ||
|
||
assertThat(memberRepository.findAll()).isEmpty(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters