From 760cc3f35780391f06c274dc1e60e066a34d2af6 Mon Sep 17 00:00:00 2001 From: jiinkyung Date: Wed, 21 Feb 2024 10:36:59 +0900 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8Feat:=20=ED=9A=8C=EC=9B=90=20=ED=83=88?= =?UTF-8?q?=ED=87=B4=20API?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/member/controller/MyPageController.java | 8 ++++++++ .../timetris/domain/member/service/MyPageService.java | 7 +++++-- .../global/auth/oauth/handler/OAuth2SuccessHandler.java | 1 - .../timetris/global/exception/enums/SuccessStatus.java | 3 ++- 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/trendithon/timetris/domain/member/controller/MyPageController.java b/src/main/java/com/trendithon/timetris/domain/member/controller/MyPageController.java index a4a41fb..6a7ba64 100644 --- a/src/main/java/com/trendithon/timetris/domain/member/controller/MyPageController.java +++ b/src/main/java/com/trendithon/timetris/domain/member/controller/MyPageController.java @@ -41,4 +41,12 @@ public ApiResponse updateName(@RequestBody UpdateNa return ApiResponse.success(SuccessStatus.OK, myPageDTO); } + + @PostMapping + @Operation(summary = "회원 탈퇴 API") + public ApiResponse userOutService(HttpServletRequest request) { + Long userId = tokenProvider.getUserId(request); + myPageService.deleteUser(userId); + return ApiResponse.success(SuccessStatus.DELETE_USER_SUCCESS); + } } diff --git a/src/main/java/com/trendithon/timetris/domain/member/service/MyPageService.java b/src/main/java/com/trendithon/timetris/domain/member/service/MyPageService.java index ccebc21..5121ec9 100644 --- a/src/main/java/com/trendithon/timetris/domain/member/service/MyPageService.java +++ b/src/main/java/com/trendithon/timetris/domain/member/service/MyPageService.java @@ -4,8 +4,6 @@ import com.trendithon.timetris.domain.member.dto.MyPageResponse; import com.trendithon.timetris.domain.member.dto.UpdateNameRequest; import com.trendithon.timetris.domain.member.repository.UserRepository; -import com.trendithon.timetris.global.exception.CustomException; -import com.trendithon.timetris.global.exception.enums.ErrorStatus; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -41,5 +39,10 @@ public MyPageResponse.getMyPageDTO updateName(Long userId, UpdateNameRequest nam .build(); } + @Transactional + public void deleteUser(Long userId) { + userRepository.deleteById(userId); + + } } diff --git a/src/main/java/com/trendithon/timetris/global/auth/oauth/handler/OAuth2SuccessHandler.java b/src/main/java/com/trendithon/timetris/global/auth/oauth/handler/OAuth2SuccessHandler.java index 5e586f3..0b6be4f 100644 --- a/src/main/java/com/trendithon/timetris/global/auth/oauth/handler/OAuth2SuccessHandler.java +++ b/src/main/java/com/trendithon/timetris/global/auth/oauth/handler/OAuth2SuccessHandler.java @@ -12,7 +12,6 @@ import org.springframework.security.web.authentication.SimpleUrlAuthenticationSuccessHandler; import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Transactional; -import org.springframework.web.util.UriComponentsBuilder; import java.io.IOException; diff --git a/src/main/java/com/trendithon/timetris/global/exception/enums/SuccessStatus.java b/src/main/java/com/trendithon/timetris/global/exception/enums/SuccessStatus.java index 82771b2..9b43b97 100644 --- a/src/main/java/com/trendithon/timetris/global/exception/enums/SuccessStatus.java +++ b/src/main/java/com/trendithon/timetris/global/exception/enums/SuccessStatus.java @@ -12,7 +12,8 @@ public enum SuccessStatus { /** * 200 OK */ - OK(HttpStatus.OK, "COMMON200", "성공입니다."); + OK(HttpStatus.OK, "COMMON200", "성공입니다."), + DELETE_USER_SUCCESS(HttpStatus.OK, "USER200", "유저 탈퇴 성공입니다."); private final HttpStatus httpStatus; private final String code;