-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/#170 관리자 관련 api 구현 #185
The head ref may contain hidden characters: "Feature/#170-\uAD00\uB9AC\uC790_\uAD00\uB828_API_\uAD6C\uD604"
Changes from 1 commit
473e43b
c7e3e94
2b61b0c
e4148fe
a88af17
3f8f58f
4b56650
6f061b2
1c93a56
31d470e
0a1625e
d3ba960
ca78cc0
dac1bfd
098a488
67f3b00
e62b873
9428736
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,8 @@ | |
import sw_css.auth.domain.repository.EmailAuthRedisRepository; | ||
import sw_css.auth.exception.AuthException; | ||
import sw_css.auth.exception.AuthExceptionType; | ||
import sw_css.member.domain.Member; | ||
import sw_css.member.domain.repository.MemberRepository; | ||
import sw_css.utils.MailUtil; | ||
|
||
@Service | ||
|
@@ -23,6 +25,7 @@ public class AuthEmailService { | |
private final MailUtil mailUtil; | ||
private final EmailAuthRedisRepository emailAuthRedisRepository; | ||
private final AuthCheckDuplicateService authCheckDuplicateService; | ||
private final MemberRepository memberRepository; | ||
|
||
public SendAuthCodeResponse emailAuth(String email) { | ||
checkIsDuplicateEmail(email); | ||
|
@@ -59,8 +62,10 @@ private void sendAuthCode(String email, String authCode) { | |
} | ||
|
||
private void checkIsDuplicateEmail(String email) { | ||
if (authCheckDuplicateService.isDuplicateEmail(email)) { | ||
throw new AuthException(AuthExceptionType.MEMBER_EMAIL_DUPLICATE); | ||
Member member = memberRepository.findByEmail(email).orElse(null); | ||
if (member == null || member.isDeleted()) { | ||
return; | ||
} | ||
throw new AuthException(AuthExceptionType.MEMBER_EMAIL_DUPLICATE); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. JPA에는 엔티티 조회 시 특정 조건에 해당되는 엔티티만 조회되도록 필터링하도록 설정할 수 있는 기능이 있습니다! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 그리고 그렇게 고친다면 아래처럼 로직을 수정하면 좋을 것 같아용 if(member!= null){
throw new AuthException(AuthExceptionType.MEMBER_EMAIL_DUPLICATE);
} |
||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
레파지토리에 접근하는 모든 서비스에는
@Transactional
을 붙여주는 것이 좋습니다!