Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ public class MemberController {

private final MemberService memberService;

@GetMapping("/member/oauth/{logintype}")
public void oauthLogin(@PathVariable("logintype") String loginType) {
@GetMapping("/member/oauth/{loginType}")
public void oauthLogin(@PathVariable("loginType") String loginType) {
memberService.oauthLogin(loginType);
}

@PostMapping("/member/oauth/{loginType}")
public void oauthRegister(@PathVariable("logintype") String loginType) {
public void oauthRegister(@PathVariable("loginType") String loginType) {
memberService.oauthRegister(loginType);
}
}
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
@@ -1,7 +1,10 @@
package com.recordit.server.service.oauth;

import org.springframework.stereotype.Service;

import com.recordit.server.constant.LoginType;

@Service
public class GoogleOauthService implements OauthService {
@Override
public LoginType getLoginType() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package com.recordit.server.service.oauth;

import org.springframework.stereotype.Service;

import com.recordit.server.constant.LoginType;

@Service
public class KakaoOauthService implements OauthService {
@Override
public LoginType getLoginType() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
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("로그인 타입이 입력되지 않았습니다.");
}
return oauthServices.stream()
.filter(oauthService -> oauthService.getLoginType().name().equals(loginType))
.findFirst()
.orElseThrow(() -> new NullPointerException("일치하는 로그인 타입이 없습니다."));
}
}