From 14ebcbf1bdb74c8fc903a85d8ad45f8167a3157c Mon Sep 17 00:00:00 2001 From: "chosw1002@naver.com" Date: Sun, 4 Feb 2024 22:20:01 +0900 Subject: [PATCH 01/18] =?UTF-8?q?feat:=20=EB=A9=A4=EB=B2=84=20=ED=83=88?= =?UTF-8?q?=ED=87=B4=20api=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gdsc/domain/member/api/AdminMemberController.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main/java/com/gdschongik/gdsc/domain/member/api/AdminMemberController.java b/src/main/java/com/gdschongik/gdsc/domain/member/api/AdminMemberController.java index f1189e103..dcedf66c3 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/member/api/AdminMemberController.java +++ b/src/main/java/com/gdschongik/gdsc/domain/member/api/AdminMemberController.java @@ -7,7 +7,9 @@ import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.http.ResponseEntity; +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.RequestMapping; import org.springframework.web.bind.annotation.RestController; @@ -23,4 +25,10 @@ public ResponseEntity> getMembers(MemberQueryRequest Page response = memberService.findAll(queryRequest, pageable); return ResponseEntity.ok().body(response); } + + @DeleteMapping("/{memberId}") + public ResponseEntity withdrawMember(@PathVariable Long memberId) { + memberService.withdrawMember(memberId); + return ResponseEntity.ok().build(); + } } From a80eae6883578d4dd60cb986a4cdbef60f1c4bb4 Mon Sep 17 00:00:00 2001 From: "chosw1002@naver.com" Date: Sun, 4 Feb 2024 22:20:19 +0900 Subject: [PATCH 02/18] =?UTF-8?q?feat:=20=EB=A9=A4=EB=B2=84=20=ED=83=88?= =?UTF-8?q?=ED=87=B4=20service=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gdsc/domain/member/application/MemberService.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/java/com/gdschongik/gdsc/domain/member/application/MemberService.java b/src/main/java/com/gdschongik/gdsc/domain/member/application/MemberService.java index 208f4c6e6..2facef4ed 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/member/application/MemberService.java +++ b/src/main/java/com/gdschongik/gdsc/domain/member/application/MemberService.java @@ -21,4 +21,9 @@ public Page findAll(MemberQueryRequest queryRequest, Page Page members = memberRepository.findAll(queryRequest, pageable); return members.map(MemberFindAllResponse::of); } + + @Transactional + public void withdrawMember(Long memberId) { + memberRepository.deleteById(memberId); + } } From 4df5b10c90361c096b31bc6a0e78a7cc5564ebdf Mon Sep 17 00:00:00 2001 From: "chosw1002@naver.com" Date: Sun, 4 Feb 2024 22:28:43 +0900 Subject: [PATCH 03/18] =?UTF-8?q?feat:=20=EB=A9=A4=EB=B2=84=20=EA=B4=80?= =?UTF-8?q?=EB=A0=A8=20=EC=97=90=EB=9F=AC=20=EC=BD=94=EB=93=9C=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/gdschongik/gdsc/global/exception/ErrorCode.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/gdschongik/gdsc/global/exception/ErrorCode.java b/src/main/java/com/gdschongik/gdsc/global/exception/ErrorCode.java index 319412314..d91f580fa 100644 --- a/src/main/java/com/gdschongik/gdsc/global/exception/ErrorCode.java +++ b/src/main/java/com/gdschongik/gdsc/global/exception/ErrorCode.java @@ -14,7 +14,10 @@ public enum ErrorCode { EXPIRED_JWT_TOKEN(HttpStatus.UNAUTHORIZED, "만료된 JWT 토큰입니다."), // Parameter - INVALID_QUERY_PARAMETER(HttpStatus.BAD_REQUEST, "잘못된 쿼리 파라미터입니다."); + INVALID_QUERY_PARAMETER(HttpStatus.BAD_REQUEST, "잘못된 쿼리 파라미터입니다."), + + // Member + MEMBER_NOT_FOUND(HttpStatus.NOT_FOUND, "존재하지 않는 회원입니다."); private final HttpStatus status; private final String message; From d331b79513c42a10a822a68a38ff6d52d1af0e7b Mon Sep 17 00:00:00 2001 From: "chosw1002@naver.com" Date: Sun, 4 Feb 2024 22:29:23 +0900 Subject: [PATCH 04/18] =?UTF-8?q?refactor:=20refresh=20=ED=86=A0=ED=81=B0?= =?UTF-8?q?=20=EC=82=AD=EC=A0=9C=20=EB=A1=9C=EC=A7=81=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gdsc/domain/member/application/MemberService.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main/java/com/gdschongik/gdsc/domain/member/application/MemberService.java b/src/main/java/com/gdschongik/gdsc/domain/member/application/MemberService.java index 2facef4ed..1d8cc3244 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/member/application/MemberService.java +++ b/src/main/java/com/gdschongik/gdsc/domain/member/application/MemberService.java @@ -1,9 +1,13 @@ package com.gdschongik.gdsc.domain.member.application; +import static com.gdschongik.gdsc.global.exception.ErrorCode.*; + +import com.gdschongik.gdsc.domain.auth.dao.RefreshTokenRepository; import com.gdschongik.gdsc.domain.member.dao.MemberRepository; import com.gdschongik.gdsc.domain.member.domain.Member; import com.gdschongik.gdsc.domain.member.dto.request.MemberQueryRequest; import com.gdschongik.gdsc.domain.member.dto.response.MemberFindAllResponse; +import com.gdschongik.gdsc.global.exception.CustomException; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; @@ -16,6 +20,7 @@ public class MemberService { private final MemberRepository memberRepository; + private final RefreshTokenRepository refreshTokenRepository; public Page findAll(MemberQueryRequest queryRequest, Pageable pageable) { Page members = memberRepository.findAll(queryRequest, pageable); @@ -24,6 +29,8 @@ public Page findAll(MemberQueryRequest queryRequest, Page @Transactional public void withdrawMember(Long memberId) { + Member member = memberRepository.findById(memberId).orElseThrow(() -> new CustomException(MEMBER_NOT_FOUND)); memberRepository.deleteById(memberId); + refreshTokenRepository.deleteById(member.getId()); } } From edac63e78eda9919c2323668a3fc29b94b6b57a8 Mon Sep 17 00:00:00 2001 From: "chosw1002@naver.com" Date: Sun, 4 Feb 2024 22:50:56 +0900 Subject: [PATCH 05/18] =?UTF-8?q?feat:=20=EC=BF=A0=ED=82=A4=20=EC=A0=9C?= =?UTF-8?q?=EA=B1=B0=20=EB=A1=9C=EC=A7=81=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gdsc/domain/member/api/AdminMemberController.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/gdschongik/gdsc/domain/member/api/AdminMemberController.java b/src/main/java/com/gdschongik/gdsc/domain/member/api/AdminMemberController.java index dcedf66c3..40b94e40c 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/member/api/AdminMemberController.java +++ b/src/main/java/com/gdschongik/gdsc/domain/member/api/AdminMemberController.java @@ -3,6 +3,8 @@ import com.gdschongik.gdsc.domain.member.application.MemberService; import com.gdschongik.gdsc.domain.member.dto.request.MemberQueryRequest; import com.gdschongik.gdsc.domain.member.dto.response.MemberFindAllResponse; +import com.gdschongik.gdsc.global.util.CookieUtil; +import jakarta.servlet.http.HttpServletResponse; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; @@ -19,6 +21,7 @@ public class AdminMemberController { private final MemberService memberService; + private final CookieUtil cookieUtil; @GetMapping public ResponseEntity> getMembers(MemberQueryRequest queryRequest, Pageable pageable) { @@ -27,8 +30,9 @@ public ResponseEntity> getMembers(MemberQueryRequest } @DeleteMapping("/{memberId}") - public ResponseEntity withdrawMember(@PathVariable Long memberId) { + public ResponseEntity withdrawMember(@PathVariable Long memberId, HttpServletResponse response) { memberService.withdrawMember(memberId); + cookieUtil.addTokenCookies(response, "", ""); return ResponseEntity.ok().build(); } } From 2ec68bcd36c4b70a62ebc1cc1d94c655c031872c Mon Sep 17 00:00:00 2001 From: "chosw1002@naver.com" Date: Mon, 5 Feb 2024 14:50:53 +0900 Subject: [PATCH 06/18] =?UTF-8?q?remove:=20=EC=BF=A0=ED=82=A4=20=EC=A0=9C?= =?UTF-8?q?=EA=B1=B0=20=EB=A1=9C=EC=A7=81=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gdsc/domain/member/api/AdminMemberController.java | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/main/java/com/gdschongik/gdsc/domain/member/api/AdminMemberController.java b/src/main/java/com/gdschongik/gdsc/domain/member/api/AdminMemberController.java index 40b94e40c..dcedf66c3 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/member/api/AdminMemberController.java +++ b/src/main/java/com/gdschongik/gdsc/domain/member/api/AdminMemberController.java @@ -3,8 +3,6 @@ import com.gdschongik.gdsc.domain.member.application.MemberService; import com.gdschongik.gdsc.domain.member.dto.request.MemberQueryRequest; import com.gdschongik.gdsc.domain.member.dto.response.MemberFindAllResponse; -import com.gdschongik.gdsc.global.util.CookieUtil; -import jakarta.servlet.http.HttpServletResponse; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; @@ -21,7 +19,6 @@ public class AdminMemberController { private final MemberService memberService; - private final CookieUtil cookieUtil; @GetMapping public ResponseEntity> getMembers(MemberQueryRequest queryRequest, Pageable pageable) { @@ -30,9 +27,8 @@ public ResponseEntity> getMembers(MemberQueryRequest } @DeleteMapping("/{memberId}") - public ResponseEntity withdrawMember(@PathVariable Long memberId, HttpServletResponse response) { + public ResponseEntity withdrawMember(@PathVariable Long memberId) { memberService.withdrawMember(memberId); - cookieUtil.addTokenCookies(response, "", ""); return ResponseEntity.ok().build(); } } From 98598d7ca9915553dfb6d1db6264057bca8c742a Mon Sep 17 00:00:00 2001 From: "chosw1002@naver.com" Date: Thu, 8 Feb 2024 15:56:32 +0900 Subject: [PATCH 07/18] =?UTF-8?q?feat:=20=EB=A9=A4=EB=B2=84=20softDelete?= =?UTF-8?q?=20=EB=A9=94=EC=84=9C=EB=93=9C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/gdschongik/gdsc/domain/member/domain/Member.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/com/gdschongik/gdsc/domain/member/domain/Member.java b/src/main/java/com/gdschongik/gdsc/domain/member/domain/Member.java index ce5375d50..75f7ae883 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/member/domain/Member.java +++ b/src/main/java/com/gdschongik/gdsc/domain/member/domain/Member.java @@ -86,4 +86,8 @@ public static Member createGuestMember(String oauthId) { .status(MemberStatus.NORMAL) .build(); } + + public void softDelete() { + this.status = MemberStatus.DELETED; + } } From a4cff031b0ae94a44a5ba82c74aba27b7ee0b096 Mon Sep 17 00:00:00 2001 From: "chosw1002@naver.com" Date: Thu, 8 Feb 2024 15:57:20 +0900 Subject: [PATCH 08/18] =?UTF-8?q?refactor:=20=EC=96=B4=EB=93=9C=EB=AF=BC?= =?UTF-8?q?=20=EB=A9=A4=EB=B2=84=20=EC=82=AD=EC=A0=9C=20softDelete?= =?UTF-8?q?=EB=A1=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gdsc/domain/member/application/MemberService.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/com/gdschongik/gdsc/domain/member/application/MemberService.java b/src/main/java/com/gdschongik/gdsc/domain/member/application/MemberService.java index 1d8cc3244..d5e27919d 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/member/application/MemberService.java +++ b/src/main/java/com/gdschongik/gdsc/domain/member/application/MemberService.java @@ -30,7 +30,6 @@ public Page findAll(MemberQueryRequest queryRequest, Page @Transactional public void withdrawMember(Long memberId) { Member member = memberRepository.findById(memberId).orElseThrow(() -> new CustomException(MEMBER_NOT_FOUND)); - memberRepository.deleteById(memberId); - refreshTokenRepository.deleteById(member.getId()); + member.softDelete(); } } From 5b37540c473172669d22bc0463baedea3e5303ba Mon Sep 17 00:00:00 2001 From: "chosw1002@naver.com" Date: Thu, 8 Feb 2024 16:53:51 +0900 Subject: [PATCH 09/18] =?UTF-8?q?fix:=20=EC=9D=B4=EB=AF=B8=20=EC=83=81?= =?UTF-8?q?=ED=83=9C=EA=B0=80=20delete=EC=9D=B8=20=EA=B2=BD=EC=9A=B0=20?= =?UTF-8?q?=EC=98=88=EC=99=B8=20=EC=B2=98=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/gdschongik/gdsc/domain/member/domain/Member.java | 6 ++++++ .../com/gdschongik/gdsc/global/exception/ErrorCode.java | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/gdschongik/gdsc/domain/member/domain/Member.java b/src/main/java/com/gdschongik/gdsc/domain/member/domain/Member.java index 75f7ae883..aa1b91225 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/member/domain/Member.java +++ b/src/main/java/com/gdschongik/gdsc/domain/member/domain/Member.java @@ -1,6 +1,9 @@ package com.gdschongik.gdsc.domain.member.domain; +import static com.gdschongik.gdsc.global.exception.ErrorCode.*; + import com.gdschongik.gdsc.domain.common.model.BaseTimeEntity; +import com.gdschongik.gdsc.global.exception.CustomException; import jakarta.persistence.Column; import jakarta.persistence.Entity; import jakarta.persistence.EnumType; @@ -88,6 +91,9 @@ public static Member createGuestMember(String oauthId) { } public void softDelete() { + if (this.status == MemberStatus.DELETED) { + throw new CustomException(MEMBER_ALREADY_SOFT_DELETED); + } this.status = MemberStatus.DELETED; } } diff --git a/src/main/java/com/gdschongik/gdsc/global/exception/ErrorCode.java b/src/main/java/com/gdschongik/gdsc/global/exception/ErrorCode.java index d91f580fa..0603a1446 100644 --- a/src/main/java/com/gdschongik/gdsc/global/exception/ErrorCode.java +++ b/src/main/java/com/gdschongik/gdsc/global/exception/ErrorCode.java @@ -17,7 +17,8 @@ public enum ErrorCode { INVALID_QUERY_PARAMETER(HttpStatus.BAD_REQUEST, "잘못된 쿼리 파라미터입니다."), // Member - MEMBER_NOT_FOUND(HttpStatus.NOT_FOUND, "존재하지 않는 회원입니다."); + MEMBER_NOT_FOUND(HttpStatus.NOT_FOUND, "존재하지 않는 회원입니다."), + MEMBER_ALREADY_SOFT_DELETED(HttpStatus.BAD_REQUEST, "이미 soft delete된 회원입니다."); private final HttpStatus status; private final String message; From d2df1efe563a77d039d8be3ceedf210f7144ce8a Mon Sep 17 00:00:00 2001 From: "chosw1002@naver.com" Date: Fri, 9 Feb 2024 12:23:07 +0900 Subject: [PATCH 10/18] =?UTF-8?q?refactor:=20soft=20deleted=20=ED=9A=8C?= =?UTF-8?q?=EC=9B=90=20=EB=A1=9C=EA=B7=B8=EC=9D=B8=20=EC=8B=9C=EB=8F=84=20?= =?UTF-8?q?=EC=8B=9C=20=EC=98=88=EC=99=B8=20=EC=B2=98=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/gdschongik/gdsc/domain/member/domain/Member.java | 4 ++++ .../gdsc/domain/member/domain/MemberStatus.java | 4 ++++ .../com/gdschongik/gdsc/global/exception/ErrorCode.java | 2 +- .../gdsc/global/security/CustomUserService.java | 9 ++++++++- 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/gdschongik/gdsc/domain/member/domain/Member.java b/src/main/java/com/gdschongik/gdsc/domain/member/domain/Member.java index aa1b91225..5da57758b 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/member/domain/Member.java +++ b/src/main/java/com/gdschongik/gdsc/domain/member/domain/Member.java @@ -96,4 +96,8 @@ public void softDelete() { } this.status = MemberStatus.DELETED; } + + public boolean isDeleted() { + return this.status.isDeleted(); + } } diff --git a/src/main/java/com/gdschongik/gdsc/domain/member/domain/MemberStatus.java b/src/main/java/com/gdschongik/gdsc/domain/member/domain/MemberStatus.java index efb05ce20..ac8cb7265 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/member/domain/MemberStatus.java +++ b/src/main/java/com/gdschongik/gdsc/domain/member/domain/MemberStatus.java @@ -11,4 +11,8 @@ public enum MemberStatus { FORBIDDEN("FORBIDDEN"); private final String value; + + public boolean isDeleted() { + return this.equals(DELETED); + } } diff --git a/src/main/java/com/gdschongik/gdsc/global/exception/ErrorCode.java b/src/main/java/com/gdschongik/gdsc/global/exception/ErrorCode.java index 0603a1446..7e3972195 100644 --- a/src/main/java/com/gdschongik/gdsc/global/exception/ErrorCode.java +++ b/src/main/java/com/gdschongik/gdsc/global/exception/ErrorCode.java @@ -18,7 +18,7 @@ public enum ErrorCode { // Member MEMBER_NOT_FOUND(HttpStatus.NOT_FOUND, "존재하지 않는 회원입니다."), - MEMBER_ALREADY_SOFT_DELETED(HttpStatus.BAD_REQUEST, "이미 soft delete된 회원입니다."); + MEMBER_SOFT_DELETED(HttpStatus.BAD_REQUEST, "soft delete된 회원입니다."); private final HttpStatus status; private final String message; diff --git a/src/main/java/com/gdschongik/gdsc/global/security/CustomUserService.java b/src/main/java/com/gdschongik/gdsc/global/security/CustomUserService.java index 5b5a08d68..33d89f7ae 100644 --- a/src/main/java/com/gdschongik/gdsc/global/security/CustomUserService.java +++ b/src/main/java/com/gdschongik/gdsc/global/security/CustomUserService.java @@ -2,6 +2,8 @@ import com.gdschongik.gdsc.domain.member.dao.MemberRepository; import com.gdschongik.gdsc.domain.member.domain.Member; +import com.gdschongik.gdsc.global.exception.CustomException; +import com.gdschongik.gdsc.global.exception.ErrorCode; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.security.oauth2.client.userinfo.DefaultOAuth2UserService; @@ -23,7 +25,12 @@ public OAuth2User loadUser(OAuth2UserRequest userRequest) throws OAuth2Authentic } private Member fetchOrCreate(OAuth2User oAuth2User) { - return memberRepository.findByOauthId(oAuth2User.getName()).orElseGet(() -> registerMember(oAuth2User)); + Member member = + memberRepository.findByOauthId(oAuth2User.getName()).orElseGet(() -> registerMember(oAuth2User)); + if (member.isDeleted()) { + throw new CustomException(ErrorCode.MEMBER_SOFT_DELETED); + } + return member; } private Member registerMember(OAuth2User oAuth2User) { From db0adef6c4f75e144a3c624db03c88f036d94f4e Mon Sep 17 00:00:00 2001 From: "chosw1002@naver.com" Date: Fri, 9 Feb 2024 12:23:35 +0900 Subject: [PATCH 11/18] =?UTF-8?q?refactor:=20=EC=83=81=ED=83=9C=20?= =?UTF-8?q?=ED=99=95=EC=9D=B8=20=EB=A1=9C=EC=A7=81=20MemberStatus=EB=A1=9C?= =?UTF-8?q?=20=EC=9D=B4=EB=8F=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/gdschongik/gdsc/domain/member/domain/Member.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/gdschongik/gdsc/domain/member/domain/Member.java b/src/main/java/com/gdschongik/gdsc/domain/member/domain/Member.java index 5da57758b..6a5ca39c3 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/member/domain/Member.java +++ b/src/main/java/com/gdschongik/gdsc/domain/member/domain/Member.java @@ -91,8 +91,8 @@ public static Member createGuestMember(String oauthId) { } public void softDelete() { - if (this.status == MemberStatus.DELETED) { - throw new CustomException(MEMBER_ALREADY_SOFT_DELETED); + if (this.status.isDeleted()) { + throw new CustomException(MEMBER_SOFT_DELETED); } this.status = MemberStatus.DELETED; } From 426f56b9e6f08a888ab064de184d4f12bc51c2e3 Mon Sep 17 00:00:00 2001 From: "chosw1002@naver.com" Date: Fri, 9 Feb 2024 15:41:49 +0900 Subject: [PATCH 12/18] =?UTF-8?q?refactor:=20=EC=A1=B0=EA=B1=B4=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/gdschongik/gdsc/domain/member/domain/Member.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/gdschongik/gdsc/domain/member/domain/Member.java b/src/main/java/com/gdschongik/gdsc/domain/member/domain/Member.java index 6a5ca39c3..9dc716d4d 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/member/domain/Member.java +++ b/src/main/java/com/gdschongik/gdsc/domain/member/domain/Member.java @@ -91,7 +91,7 @@ public static Member createGuestMember(String oauthId) { } public void softDelete() { - if (this.status.isDeleted()) { + if (isDeleted()) { throw new CustomException(MEMBER_SOFT_DELETED); } this.status = MemberStatus.DELETED; From 5126fa769f6f4aead3ba6399b8f60e885f5e9600 Mon Sep 17 00:00:00 2001 From: "chosw1002@naver.com" Date: Fri, 9 Feb 2024 15:56:22 +0900 Subject: [PATCH 13/18] =?UTF-8?q?fix:=20=EC=9E=AC=EA=B0=80=EC=9E=85=20?= =?UTF-8?q?=EA=B0=80=EB=8A=A5=ED=95=98=EB=8F=84=EB=A1=9D=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../member/dao/MemberCustomRepository.java | 3 +++ .../member/dao/MemberCustomRepositoryImpl.java | 18 ++++++++++++++++++ .../global/security/CustomUserService.java | 9 +-------- 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/gdschongik/gdsc/domain/member/dao/MemberCustomRepository.java b/src/main/java/com/gdschongik/gdsc/domain/member/dao/MemberCustomRepository.java index b7458d7d6..85a6a9436 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/member/dao/MemberCustomRepository.java +++ b/src/main/java/com/gdschongik/gdsc/domain/member/dao/MemberCustomRepository.java @@ -2,9 +2,12 @@ import com.gdschongik.gdsc.domain.member.domain.Member; import com.gdschongik.gdsc.domain.member.dto.request.MemberQueryRequest; +import java.util.Optional; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; public interface MemberCustomRepository { Page findAll(MemberQueryRequest queryRequest, Pageable pageable); + + Optional findNormalByOauthId(String oauthId); } diff --git a/src/main/java/com/gdschongik/gdsc/domain/member/dao/MemberCustomRepositoryImpl.java b/src/main/java/com/gdschongik/gdsc/domain/member/dao/MemberCustomRepositoryImpl.java index e8ca112d0..e2e0f1844 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/member/dao/MemberCustomRepositoryImpl.java +++ b/src/main/java/com/gdschongik/gdsc/domain/member/dao/MemberCustomRepositoryImpl.java @@ -3,12 +3,14 @@ import static com.gdschongik.gdsc.domain.member.domain.QMember.*; import com.gdschongik.gdsc.domain.member.domain.Member; +import com.gdschongik.gdsc.domain.member.domain.MemberStatus; import com.gdschongik.gdsc.domain.member.dto.request.MemberQueryRequest; import com.querydsl.core.BooleanBuilder; import com.querydsl.core.types.dsl.BooleanExpression; import com.querydsl.jpa.impl.JPAQuery; import com.querydsl.jpa.impl.JPAQueryFactory; import java.util.List; +import java.util.Optional; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; @@ -34,6 +36,22 @@ public Page findAll(MemberQueryRequest queryRequest, Pageable pageable) return PageableExecutionUtils.getPage(fetch, pageable, countQuery::fetchOne); } + @Override + public Optional findNormalByOauthId(String oauthId) { + return Optional.ofNullable(queryFactory + .selectFrom(member) + .where(eqOauthId(oauthId), eqStatus(MemberStatus.NORMAL)) + .fetchOne()); + } + + private BooleanExpression eqOauthId(String oauthId) { + return member.oauthId.eq(oauthId); + } + + private BooleanExpression eqStatus(MemberStatus status) { + return member.status.eq(status); + } + private BooleanBuilder queryOption(MemberQueryRequest queryRequest) { BooleanBuilder booleanBuilder = new BooleanBuilder(); diff --git a/src/main/java/com/gdschongik/gdsc/global/security/CustomUserService.java b/src/main/java/com/gdschongik/gdsc/global/security/CustomUserService.java index 33d89f7ae..affb8e41b 100644 --- a/src/main/java/com/gdschongik/gdsc/global/security/CustomUserService.java +++ b/src/main/java/com/gdschongik/gdsc/global/security/CustomUserService.java @@ -2,8 +2,6 @@ import com.gdschongik.gdsc.domain.member.dao.MemberRepository; import com.gdschongik.gdsc.domain.member.domain.Member; -import com.gdschongik.gdsc.global.exception.CustomException; -import com.gdschongik.gdsc.global.exception.ErrorCode; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.security.oauth2.client.userinfo.DefaultOAuth2UserService; @@ -25,12 +23,7 @@ public OAuth2User loadUser(OAuth2UserRequest userRequest) throws OAuth2Authentic } private Member fetchOrCreate(OAuth2User oAuth2User) { - Member member = - memberRepository.findByOauthId(oAuth2User.getName()).orElseGet(() -> registerMember(oAuth2User)); - if (member.isDeleted()) { - throw new CustomException(ErrorCode.MEMBER_SOFT_DELETED); - } - return member; + return memberRepository.findNormalByOauthId(oAuth2User.getName()).orElseGet(() -> registerMember(oAuth2User)); } private Member registerMember(OAuth2User oAuth2User) { From bd60c5be1f5d94291288ec81586856ce6bbbaac4 Mon Sep 17 00:00:00 2001 From: "chosw1002@naver.com" Date: Fri, 9 Feb 2024 15:57:08 +0900 Subject: [PATCH 14/18] =?UTF-8?q?remove:=20=EC=82=AC=EC=9A=A9=ED=95=98?= =?UTF-8?q?=EC=A7=80=20=EC=95=8A=EB=8A=94=20=EB=A9=94=EC=84=9C=EB=93=9C=20?= =?UTF-8?q?=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gdschongik/gdsc/domain/member/dao/MemberRepository.java | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/main/java/com/gdschongik/gdsc/domain/member/dao/MemberRepository.java b/src/main/java/com/gdschongik/gdsc/domain/member/dao/MemberRepository.java index 2839662a2..5fc3e0c88 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/member/dao/MemberRepository.java +++ b/src/main/java/com/gdschongik/gdsc/domain/member/dao/MemberRepository.java @@ -1,10 +1,6 @@ package com.gdschongik.gdsc.domain.member.dao; import com.gdschongik.gdsc.domain.member.domain.Member; -import java.util.Optional; import org.springframework.data.jpa.repository.JpaRepository; -public interface MemberRepository extends JpaRepository, MemberCustomRepository { - - Optional findByOauthId(String oauthId); -} +public interface MemberRepository extends JpaRepository, MemberCustomRepository {} From 2c67d19966da9dabf68adce11647f7fc1148a97d Mon Sep 17 00:00:00 2001 From: "chosw1002@naver.com" Date: Fri, 9 Feb 2024 19:13:03 +0900 Subject: [PATCH 15/18] =?UTF-8?q?fix:=20=EC=97=90=EB=9F=AC=20=EC=BD=94?= =?UTF-8?q?=EB=93=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/gdschongik/gdsc/domain/member/domain/Member.java | 2 +- .../java/com/gdschongik/gdsc/global/exception/ErrorCode.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/gdschongik/gdsc/domain/member/domain/Member.java b/src/main/java/com/gdschongik/gdsc/domain/member/domain/Member.java index 9dc716d4d..1913ecaab 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/member/domain/Member.java +++ b/src/main/java/com/gdschongik/gdsc/domain/member/domain/Member.java @@ -92,7 +92,7 @@ public static Member createGuestMember(String oauthId) { public void softDelete() { if (isDeleted()) { - throw new CustomException(MEMBER_SOFT_DELETED); + throw new CustomException(MEMBER_DELETED); } this.status = MemberStatus.DELETED; } diff --git a/src/main/java/com/gdschongik/gdsc/global/exception/ErrorCode.java b/src/main/java/com/gdschongik/gdsc/global/exception/ErrorCode.java index 7e3972195..feb4b7a9d 100644 --- a/src/main/java/com/gdschongik/gdsc/global/exception/ErrorCode.java +++ b/src/main/java/com/gdschongik/gdsc/global/exception/ErrorCode.java @@ -18,7 +18,7 @@ public enum ErrorCode { // Member MEMBER_NOT_FOUND(HttpStatus.NOT_FOUND, "존재하지 않는 회원입니다."), - MEMBER_SOFT_DELETED(HttpStatus.BAD_REQUEST, "soft delete된 회원입니다."); + MEMBER_DELETED(HttpStatus.BAD_REQUEST, "탈퇴한 회원입니다."); private final HttpStatus status; private final String message; From 22b97d4d24b6de8ffc98bb460737a080acf9a70a Mon Sep 17 00:00:00 2001 From: "chosw1002@naver.com" Date: Fri, 9 Feb 2024 19:13:24 +0900 Subject: [PATCH 16/18] =?UTF-8?q?fix:=20=EB=A9=94=EC=84=9C=EB=93=9C?= =?UTF-8?q?=EB=AA=85=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gdsc/domain/member/application/MemberService.java | 2 +- .../java/com/gdschongik/gdsc/domain/member/domain/Member.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/gdschongik/gdsc/domain/member/application/MemberService.java b/src/main/java/com/gdschongik/gdsc/domain/member/application/MemberService.java index d5e27919d..a97c7eec1 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/member/application/MemberService.java +++ b/src/main/java/com/gdschongik/gdsc/domain/member/application/MemberService.java @@ -30,6 +30,6 @@ public Page findAll(MemberQueryRequest queryRequest, Page @Transactional public void withdrawMember(Long memberId) { Member member = memberRepository.findById(memberId).orElseThrow(() -> new CustomException(MEMBER_NOT_FOUND)); - member.softDelete(); + member.withdraw(); } } diff --git a/src/main/java/com/gdschongik/gdsc/domain/member/domain/Member.java b/src/main/java/com/gdschongik/gdsc/domain/member/domain/Member.java index 1913ecaab..5c41d7947 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/member/domain/Member.java +++ b/src/main/java/com/gdschongik/gdsc/domain/member/domain/Member.java @@ -90,7 +90,7 @@ public static Member createGuestMember(String oauthId) { .build(); } - public void softDelete() { + public void withdraw() { if (isDeleted()) { throw new CustomException(MEMBER_DELETED); } From a40be92c9af38ed6be3701d0cd095dec327358be Mon Sep 17 00:00:00 2001 From: "chosw1002@naver.com" Date: Fri, 9 Feb 2024 19:14:49 +0900 Subject: [PATCH 17/18] =?UTF-8?q?remove:=20=EC=82=AC=EC=9A=A9=ED=95=98?= =?UTF-8?q?=EC=A7=80=20=EC=95=8A=EB=8A=94=20=EC=9D=98=EC=A1=B4=EC=84=B1=20?= =?UTF-8?q?=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gdsc/domain/member/application/MemberService.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/main/java/com/gdschongik/gdsc/domain/member/application/MemberService.java b/src/main/java/com/gdschongik/gdsc/domain/member/application/MemberService.java index a97c7eec1..2933d7d2a 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/member/application/MemberService.java +++ b/src/main/java/com/gdschongik/gdsc/domain/member/application/MemberService.java @@ -2,7 +2,6 @@ import static com.gdschongik.gdsc.global.exception.ErrorCode.*; -import com.gdschongik.gdsc.domain.auth.dao.RefreshTokenRepository; import com.gdschongik.gdsc.domain.member.dao.MemberRepository; import com.gdschongik.gdsc.domain.member.domain.Member; import com.gdschongik.gdsc.domain.member.dto.request.MemberQueryRequest; @@ -20,7 +19,6 @@ public class MemberService { private final MemberRepository memberRepository; - private final RefreshTokenRepository refreshTokenRepository; public Page findAll(MemberQueryRequest queryRequest, Pageable pageable) { Page members = memberRepository.findAll(queryRequest, pageable); From 534cb246a0232e60cd2bb072638fb19892c462e2 Mon Sep 17 00:00:00 2001 From: "chosw1002@naver.com" Date: Fri, 9 Feb 2024 20:12:47 +0900 Subject: [PATCH 18/18] =?UTF-8?q?fix:=20=EC=83=81=ED=83=9C=EC=BD=94?= =?UTF-8?q?=EB=93=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/gdschongik/gdsc/global/exception/ErrorCode.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/gdschongik/gdsc/global/exception/ErrorCode.java b/src/main/java/com/gdschongik/gdsc/global/exception/ErrorCode.java index feb4b7a9d..4bf8434d3 100644 --- a/src/main/java/com/gdschongik/gdsc/global/exception/ErrorCode.java +++ b/src/main/java/com/gdschongik/gdsc/global/exception/ErrorCode.java @@ -18,7 +18,7 @@ public enum ErrorCode { // Member MEMBER_NOT_FOUND(HttpStatus.NOT_FOUND, "존재하지 않는 회원입니다."), - MEMBER_DELETED(HttpStatus.BAD_REQUEST, "탈퇴한 회원입니다."); + MEMBER_DELETED(HttpStatus.CONFLICT, "탈퇴한 회원입니다."); private final HttpStatus status; private final String message;