-
Notifications
You must be signed in to change notification settings - Fork 0
[BE-55] OauthServiceLocator 생성 #25
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
Changes from 3 commits
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 |
|---|---|---|
| @@ -1,26 +1,25 @@ | ||
| package com.recordit.server.service; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| import org.springframework.stereotype.Service; | ||
| import org.springframework.transaction.annotation.Transactional; | ||
|
|
||
| import com.recordit.server.service.oauth.OauthService; | ||
| import com.recordit.server.service.oauth.OauthServiceLocator; | ||
|
|
||
| import lombok.RequiredArgsConstructor; | ||
|
|
||
| @Service | ||
| @RequiredArgsConstructor | ||
| public class MemberService { | ||
| private final List<OauthService> oauthServices; | ||
| private final OauthServiceLocator oauthServiceLocator; | ||
|
|
||
| @Transactional | ||
| public void oauthLogin(String loginType) { | ||
|
|
||
| OauthService oauthService = oauthServiceLocator.getOauthServiceByLoginType(loginType); | ||
| } | ||
|
|
||
| @Transactional | ||
| public void oauthRegister(String loginType) { | ||
|
|
||
| OauthService oauthService = oauthServiceLocator.getOauthServiceByLoginType(loginType); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| package com.recordit.server.service.oauth; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| import org.springframework.stereotype.Component; | ||
| import org.springframework.util.StringUtils; | ||
|
|
||
| import lombok.RequiredArgsConstructor; | ||
|
|
||
| @Component | ||
| @RequiredArgsConstructor | ||
| public class OauthServiceLocator { | ||
| private final List<OauthService> oauthServices; | ||
|
|
||
| public OauthService getOauthServiceByLoginType(String loginType) { | ||
| if (!StringUtils.hasText(loginType)) { | ||
| throw new NullPointerException("로그인 타입이 없습니다."); | ||
| } | ||
| for (OauthService service : oauthServices) { | ||
|
||
| if (loginType.equals(service.getLoginType().name())) { | ||
| return service; | ||
| } | ||
| } | ||
| throw new NullPointerException("일치하는 로그인 타입이 없습니다."); | ||
| } | ||
| } | ||
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.
'로그인 타입이 없습니다.' 보다는 '로그인 타입이 입력되지 않았습니다.' 이렇게 조금 더 명시적으로 하는게 어떨까요?
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.
좋습니다!!