From 47152dab32f5310657396da5288a73864365aaa0 Mon Sep 17 00:00:00 2001 From: easyoungcode Date: Sat, 10 Feb 2024 23:56:39 +0900 Subject: [PATCH] =?UTF-8?q?[CHORE]=20=EC=9D=B4=EB=A9=94=EC=9D=BC=20?= =?UTF-8?q?=EC=9D=B8=EC=A6=9D=20=EA=B3=BC=EC=A0=95=20=EC=A4=91=20=ED=95=B4?= =?UTF-8?q?=EB=8B=B9=20=EC=9C=A0=EC=A0=80=EC=9D=98=20=ED=9A=8C=EC=9B=90?= =?UTF-8?q?=EA=B0=80=EC=9E=85=20=EA=B3=BC=EC=A0=95=20=EC=A7=84=ED=96=89=20?= =?UTF-8?q?=EC=83=81=ED=83=9C=EC=97=90=20=EB=94=B0=EB=A5=B8=20responseStat?= =?UTF-8?q?usName=20=EC=88=98=EC=A0=95=20=EB=B0=8F=20ProfileRepository=20O?= =?UTF-8?q?ptionalfindByUser=20=EC=B6=94=EA=B0=80=201.=20?= =?UTF-8?q?=EC=9D=B4=EB=A9=94=EC=9D=BC=20=EC=9D=B8=EC=A6=9D=20=EA=B3=BC?= =?UTF-8?q?=EC=A0=95=20=EC=A4=91=20=ED=95=B4=EB=8B=B9=20=EC=9C=A0=EC=A0=80?= =?UTF-8?q?=EC=9D=98=20=ED=9A=8C=EC=9B=90=EA=B0=80=EC=9E=85=20=EA=B3=BC?= =?UTF-8?q?=EC=A0=95=20=EC=A7=84=ED=96=89=20=EC=83=81=ED=83=9C=EC=97=90=20?= =?UTF-8?q?=EB=94=B0=EB=A5=B8=20Response=ED=95=98=EB=8A=94=20statusName=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80=20(duplicated=20:=20=EC=A4=91=EB=B3=B5=20/?= =?UTF-8?q?=20completed=20:=20=EC=9D=B4=EB=AF=B8=20=EC=9D=B8=EC=A6=9D?= =?UTF-8?q?=EB=90=9C=20=EC=9D=B4=EB=A9=94=EC=9D=BC=20/=20ExistsUser=20:=20?= =?UTF-8?q?=EC=9D=B4=EB=AF=B8=20=EC=A1=B4=EC=9E=AC=ED=95=98=EB=8A=94=20?= =?UTF-8?q?=EC=82=AC=EC=9A=A9=EC=9E=90=20/=20ExistsProfile=20:=20=ED=94=84?= =?UTF-8?q?=EB=A1=9C=ED=95=84=20=EB=93=B1=EB=A1=9D=EA=B9=8C=EC=A7=80=20?= =?UTF-8?q?=EC=99=84=EB=A3=8C=ED=95=9C=20=EC=82=AC=EC=9A=A9=EC=9E=90)=202.?= =?UTF-8?q?=20Profile=20Entity=20=EB=82=B4=20Builder=EC=97=90=20User=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80=203.=20ProfileRepository=EC=97=90=20Optional?= =?UTF-8?q?findByUser=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/wooyeon/yeon/user/domain/Profile.java | 3 ++- .../yeon/user/repository/ProfileRepository.java | 3 +++ .../yeon/user/service/EmailAuthService.java | 16 ++++++++++++---- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/wooyeon/yeon/user/domain/Profile.java b/src/main/java/com/wooyeon/yeon/user/domain/Profile.java index bb0338e..5f0a666 100644 --- a/src/main/java/com/wooyeon/yeon/user/domain/Profile.java +++ b/src/main/java/com/wooyeon/yeon/user/domain/Profile.java @@ -50,7 +50,7 @@ public class Profile { private boolean faceVerify; @Builder - public Profile(char gender, String nickname, List profilePhotos, String birthday, String gpsLocationInfo, String mbti, String intro, String hobby, String interest, boolean faceVerify) { + public Profile(char gender, String nickname, List profilePhotos, String birthday, String gpsLocationInfo, String mbti, String intro, String hobby, String interest, boolean faceVerify, User user) { this.gender = gender; this.nickname = nickname; this.profilePhotos = profilePhotos; @@ -61,5 +61,6 @@ public Profile(char gender, String nickname, List profilePhotos, S this.hobby = hobby; this.interest = interest; this.faceVerify = faceVerify; + this.user = user; } } \ No newline at end of file diff --git a/src/main/java/com/wooyeon/yeon/user/repository/ProfileRepository.java b/src/main/java/com/wooyeon/yeon/user/repository/ProfileRepository.java index 5a14fd2..37c42d7 100644 --- a/src/main/java/com/wooyeon/yeon/user/repository/ProfileRepository.java +++ b/src/main/java/com/wooyeon/yeon/user/repository/ProfileRepository.java @@ -1,6 +1,7 @@ package com.wooyeon.yeon.user.repository; import com.wooyeon.yeon.user.domain.Profile; +import com.wooyeon.yeon.user.domain.User; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; @@ -9,4 +10,6 @@ @Repository public interface ProfileRepository extends JpaRepository { Optional findByNicknameContains(String searchWord); + + Optional findByUser(User user); } diff --git a/src/main/java/com/wooyeon/yeon/user/service/EmailAuthService.java b/src/main/java/com/wooyeon/yeon/user/service/EmailAuthService.java index 7668cf2..a18e121 100644 --- a/src/main/java/com/wooyeon/yeon/user/service/EmailAuthService.java +++ b/src/main/java/com/wooyeon/yeon/user/service/EmailAuthService.java @@ -1,10 +1,12 @@ package com.wooyeon.yeon.user.service; import com.wooyeon.yeon.user.domain.EmailAuth; +import com.wooyeon.yeon.user.domain.User; import com.wooyeon.yeon.user.dto.emailAuth.EmailAuthResponseDto; import com.wooyeon.yeon.user.dto.emailAuth.EmailRequestDto; import com.wooyeon.yeon.user.dto.emailAuth.EmailResponseDto; import com.wooyeon.yeon.user.repository.EmailAuthRepository; +import com.wooyeon.yeon.user.repository.ProfileRepository; import com.wooyeon.yeon.user.repository.UserRepository; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -36,6 +38,7 @@ public class EmailAuthService { private final EmailAuthRepository emailAuthRepository; private final JavaMailSender mailSender; private final SpringTemplateEngine templateEngine; + private final ProfileRepository profileRepository; // authToken 만료 시간 (10분) private static final long EXPIRATION_TIME = 10 * 60 * 1000; @@ -69,13 +72,18 @@ public EmailResponseDto sendEmail(EmailRequestDto emailRequestDto) throws Messag Optional emailAuthOptional = emailAuthRepository.findEmailAuthByEmail(emailRequestDto.getEmail()); if (emailAuthOptional.isPresent() && emailAuthOptional.get().isCertification()) { // 해당 이메일이 이미 인증된 경우 - if (userRepository.findByEmail(emailRequestDto.getEmail()) != null) { - emailResponseDto.updateStatusName("ExistsUser"); + User findUser = userRepository.findByEmail(emailRequestDto.getEmail()); + if (findUser != null) { + if(profileRepository.findByUser(findUser).isPresent()) { + emailResponseDto.updateStatusName("ExistsProfile"); // 회원가입 완료 & 프로필 존재 + } else { + emailResponseDto.updateStatusName("ExistsUser"); // 유저 존재 (회원가입 과정 완료) + } } else { - emailResponseDto.updateStatusName("completed"); + emailResponseDto.updateStatusName("completed"); // 이메일 인증 완료 } } else { - emailResponseDto.updateStatusName("duplicated"); + emailResponseDto.updateStatusName("duplicated"); // 이메일 인증이 완료된 상태 (그러나 회원가입 완료는 아님) } return emailResponseDto; } else {