-
Notifications
You must be signed in to change notification settings - Fork 0
[REFACTOR/#179] 외부 API 요청 트랜잭션 분리를 위한 Facade 패턴 도입 #180
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
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
9a7a5e2
[FEAT] MeberController - Service단 사이에 AuthFacade 도입
JungYoonShin c2f895c
[TEST] AuthFacadeTest 테스트코드 작성
JungYoonShin 0253c33
[REFACTOR] 필요없는 주석 삭제
JungYoonShin ef8a074
[FIX] 일반/ 카카오 로그인 타입에 따라 값 다르게 저장되도록 수정
JungYoonShin 22f050b
[REFACTOR] MemberService, TokenService 분리
JungYoonShin ac5bb09
[REFACTOR] 토큰 발급 메서드 분리 (엑세스, 리프레시)
JungYoonShin d7978e6
[FIX] StringRedisTemplate에서 RedisTemplate<String, String>으로 변경
JungYoonShin 4aa49c1
[FIX] MemberRepositoryTest에서 유저 생성 시 LoginType 추가
JungYoonShin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
72 changes: 72 additions & 0 deletions
72
src/main/java/com/favoriteplace/app/member/Facade/AuthFacade.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| package com.favoriteplace.app.member.Facade; | ||
|
|
||
| import com.favoriteplace.app.member.controller.dto.KaKaoSignUpRequestDto; | ||
| import com.favoriteplace.app.member.controller.dto.MemberDto; | ||
| import com.favoriteplace.app.member.controller.dto.MemberSignUpReqDto; | ||
| import com.favoriteplace.app.member.controller.dto.TokenInfoDto; | ||
| import com.favoriteplace.app.member.domain.Member; | ||
| import com.favoriteplace.app.member.service.MemberService; | ||
| import com.favoriteplace.app.member.service.TokenService; | ||
| import com.favoriteplace.global.auth.kakao.KakaoClient; | ||
| import com.favoriteplace.global.auth.provider.JwtTokenProvider; | ||
|
|
||
| import lombok.RequiredArgsConstructor; | ||
|
|
||
| import org.springframework.security.core.Authentication; | ||
| import org.springframework.stereotype.Component; | ||
| import org.springframework.web.multipart.MultipartFile; | ||
|
|
||
| import java.io.IOException; | ||
| import java.util.List; | ||
|
|
||
| @Component | ||
| @RequiredArgsConstructor | ||
| public class AuthFacade { | ||
| private final MemberService memberService; | ||
| private final TokenService tokenService; | ||
| private final JwtTokenProvider jwtTokenProvider; | ||
| private final KakaoClient kakaoClient; | ||
|
|
||
| public TokenInfoDto kakaoLogin(final String token) { | ||
| String email = kakaoClient.getUserInfo(token).kakaoAccount().email(); | ||
| memberService.kakaoLogin(email); | ||
| return getTokenDto(email); | ||
| } | ||
|
|
||
| public MemberDto.MemberSignUpResDto kakaoSignUp( | ||
| final String token, | ||
| final KaKaoSignUpRequestDto memberSignUpReqDto, | ||
| final List<MultipartFile> images | ||
| ) throws IOException { | ||
| String email = kakaoClient.getUserInfo(token).kakaoAccount().email(); | ||
| TokenInfoDto tokenDto = getTokenDto(email); | ||
| Member member = memberService.kakaoSignUp(email, memberSignUpReqDto, images); | ||
| tokenService.updateRefreshToken(member, tokenDto.refreshToken()); | ||
| return MemberDto.MemberSignUpResDto.from(member, tokenDto); | ||
| } | ||
|
|
||
| public MemberDto.MemberSignUpResDto signup( | ||
| final MemberSignUpReqDto memberSignUpReqDto, | ||
| final List<MultipartFile> images | ||
| ) throws IOException { | ||
| Member member = memberService.signup(memberSignUpReqDto, images); | ||
| TokenInfoDto tokenDto = getTokenDto(member.getEmail()); | ||
| tokenService.updateRefreshToken(member, tokenDto.refreshToken()); | ||
| return MemberDto.MemberSignUpResDto.from(member, tokenDto); | ||
| } | ||
|
|
||
| public void logout(String accessToken) { | ||
| Authentication authentication = jwtTokenProvider.getAuthentication(accessToken); | ||
| String email = authentication.getName(); | ||
| Long expiration = jwtTokenProvider.getExpiration(accessToken); | ||
| Member member = memberService.findMember(email); | ||
| tokenService.logoutAndInvalidateToken(member, expiration, accessToken); | ||
| } | ||
|
|
||
| private TokenInfoDto getTokenDto(String email) { | ||
| return TokenInfoDto.of( | ||
| jwtTokenProvider.issueAccessToken(email), | ||
| jwtTokenProvider.issueRefreshToken(email) | ||
| ); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.