From b88fc888b938e512528563760baf2fa30f4752fe Mon Sep 17 00:00:00 2001 From: Haebin Date: Sun, 17 Mar 2024 08:22:12 +0900 Subject: [PATCH] =?UTF-8?q?chore:=20=ED=8C=A8=ED=82=A4=EC=A7=80=20?= =?UTF-8?q?=EA=B5=AC=EC=A1=B0=20=EA=B0=9C=EC=84=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../backend/application/auth/AuthFactory.kt | 2 +- .../backend/application/auth/AuthService.kt | 6 +++--- .../application/auth/dto/KakaoMemberResponse.kt | 5 +++++ .../application/auth/dto/LoginResponse.kt | 6 ++++++ .../application/auth/dto/MemberResponse.kt | 2 +- .../dto/{OauthToken.kt => OauthTokenResponse.kt} | 2 +- .../vacgom/backend/domain/auth/AuthConnector.kt | 10 +++++----- .../backend/domain/auth/AuthUriGenerator.kt | 2 +- .../domain/{member => auth}/RefreshToken.kt | 3 ++- .../{member => auth}/constants/ProviderType.kt | 2 +- .../domain/{member => auth}/constants/Role.kt | 2 +- .../com/vacgom/backend/domain/member/Member.kt | 6 +++--- .../auth/kakao/KakaoAuthConnector.kt | 16 ++++++++-------- .../auth/kakao/KakaoUriGenerator.kt | 4 ++-- .../auth/kakao/model/KakaoMemberInfo.kt | 5 ----- .../auth/kakao/model}/KakaoProperties.kt | 2 +- .../persistence}/RefreshTokenRepository.kt | 4 ++-- .../member/{ => persistence}/MemberRepository.kt | 4 ++-- 18 files changed, 45 insertions(+), 38 deletions(-) create mode 100644 src/main/kotlin/com/vacgom/backend/application/auth/dto/KakaoMemberResponse.kt create mode 100644 src/main/kotlin/com/vacgom/backend/application/auth/dto/LoginResponse.kt rename src/main/kotlin/com/vacgom/backend/application/auth/dto/{OauthToken.kt => OauthTokenResponse.kt} (81%) rename src/main/kotlin/com/vacgom/backend/domain/{member => auth}/RefreshToken.kt (83%) rename src/main/kotlin/com/vacgom/backend/domain/{member => auth}/constants/ProviderType.kt (90%) rename src/main/kotlin/com/vacgom/backend/domain/{member => auth}/constants/Role.kt (51%) delete mode 100644 src/main/kotlin/com/vacgom/backend/infrastructure/auth/kakao/model/KakaoMemberInfo.kt rename src/main/kotlin/com/vacgom/backend/{application/auth/property => infrastructure/auth/kakao/model}/KakaoProperties.kt (93%) rename src/main/kotlin/com/vacgom/backend/infrastructure/{member => auth/persistence}/RefreshTokenRepository.kt (57%) rename src/main/kotlin/com/vacgom/backend/infrastructure/member/{ => persistence}/MemberRepository.kt (72%) diff --git a/src/main/kotlin/com/vacgom/backend/application/auth/AuthFactory.kt b/src/main/kotlin/com/vacgom/backend/application/auth/AuthFactory.kt index 761bda4..600473a 100644 --- a/src/main/kotlin/com/vacgom/backend/application/auth/AuthFactory.kt +++ b/src/main/kotlin/com/vacgom/backend/application/auth/AuthFactory.kt @@ -2,7 +2,7 @@ package com.vacgom.backend.application.auth import com.vacgom.backend.domain.auth.AuthConnector import com.vacgom.backend.domain.auth.AuthUriGenerator -import com.vacgom.backend.domain.member.constants.ProviderType +import com.vacgom.backend.domain.auth.constants.ProviderType import com.vacgom.backend.global.exception.error.BusinessException import com.vacgom.backend.global.security.exception.AuthError import org.springframework.stereotype.Component diff --git a/src/main/kotlin/com/vacgom/backend/application/auth/AuthService.kt b/src/main/kotlin/com/vacgom/backend/application/auth/AuthService.kt index 772bbb5..c800923 100644 --- a/src/main/kotlin/com/vacgom/backend/application/auth/AuthService.kt +++ b/src/main/kotlin/com/vacgom/backend/application/auth/AuthService.kt @@ -1,10 +1,10 @@ package com.vacgom.backend.application.auth import com.vacgom.backend.application.auth.dto.MemberResponse +import com.vacgom.backend.domain.auth.constants.ProviderType +import com.vacgom.backend.domain.auth.constants.Role import com.vacgom.backend.domain.member.Member -import com.vacgom.backend.domain.member.constants.ProviderType -import com.vacgom.backend.domain.member.constants.Role -import com.vacgom.backend.infrastructure.member.MemberRepository +import com.vacgom.backend.infrastructure.member.persistence.MemberRepository import jakarta.transaction.Transactional import org.springframework.http.HttpHeaders import org.springframework.stereotype.Service diff --git a/src/main/kotlin/com/vacgom/backend/application/auth/dto/KakaoMemberResponse.kt b/src/main/kotlin/com/vacgom/backend/application/auth/dto/KakaoMemberResponse.kt new file mode 100644 index 0000000..1d9fb41 --- /dev/null +++ b/src/main/kotlin/com/vacgom/backend/application/auth/dto/KakaoMemberResponse.kt @@ -0,0 +1,5 @@ +package com.vacgom.backend.application.auth.dto + +data class KakaoMemberResponse( + var id: Long +) diff --git a/src/main/kotlin/com/vacgom/backend/application/auth/dto/LoginResponse.kt b/src/main/kotlin/com/vacgom/backend/application/auth/dto/LoginResponse.kt new file mode 100644 index 0000000..f1c3e1c --- /dev/null +++ b/src/main/kotlin/com/vacgom/backend/application/auth/dto/LoginResponse.kt @@ -0,0 +1,6 @@ +package com.vacgom.backend.application.auth.dto + +data class LoginResponse( + val member: MemberResponse, + val token: TokenResponse +) diff --git a/src/main/kotlin/com/vacgom/backend/application/auth/dto/MemberResponse.kt b/src/main/kotlin/com/vacgom/backend/application/auth/dto/MemberResponse.kt index b0b7ceb..777344f 100644 --- a/src/main/kotlin/com/vacgom/backend/application/auth/dto/MemberResponse.kt +++ b/src/main/kotlin/com/vacgom/backend/application/auth/dto/MemberResponse.kt @@ -1,6 +1,6 @@ package com.vacgom.backend.application.auth.dto -import com.vacgom.backend.domain.member.constants.Role +import com.vacgom.backend.domain.auth.constants.Role import java.util.* data class MemberResponse( diff --git a/src/main/kotlin/com/vacgom/backend/application/auth/dto/OauthToken.kt b/src/main/kotlin/com/vacgom/backend/application/auth/dto/OauthTokenResponse.kt similarity index 81% rename from src/main/kotlin/com/vacgom/backend/application/auth/dto/OauthToken.kt rename to src/main/kotlin/com/vacgom/backend/application/auth/dto/OauthTokenResponse.kt index aaa9dce..9a39430 100644 --- a/src/main/kotlin/com/vacgom/backend/application/auth/dto/OauthToken.kt +++ b/src/main/kotlin/com/vacgom/backend/application/auth/dto/OauthTokenResponse.kt @@ -4,4 +4,4 @@ import com.fasterxml.jackson.databind.PropertyNamingStrategies import com.fasterxml.jackson.databind.annotation.JsonNaming @JsonNaming(value = PropertyNamingStrategies.SnakeCaseStrategy::class) -data class OauthToken(val accessToken: String) +data class OauthTokenResponse(val accessToken: String) diff --git a/src/main/kotlin/com/vacgom/backend/domain/auth/AuthConnector.kt b/src/main/kotlin/com/vacgom/backend/domain/auth/AuthConnector.kt index 5b66165..78e17f4 100644 --- a/src/main/kotlin/com/vacgom/backend/domain/auth/AuthConnector.kt +++ b/src/main/kotlin/com/vacgom/backend/domain/auth/AuthConnector.kt @@ -1,11 +1,11 @@ package com.vacgom.backend.domain.auth -import com.vacgom.backend.application.auth.dto.OauthToken -import com.vacgom.backend.domain.member.constants.ProviderType -import com.vacgom.backend.infrastructure.auth.kakao.model.KakaoMemberInfo +import com.vacgom.backend.application.auth.dto.KakaoMemberResponse +import com.vacgom.backend.application.auth.dto.OauthTokenResponse +import com.vacgom.backend.domain.auth.constants.ProviderType interface AuthConnector { fun isSupported(provider: ProviderType): Boolean - fun fetchOauthToken(code: String): OauthToken - fun fetchMemberInfo(accessToken: String): KakaoMemberInfo + fun fetchOauthToken(code: String): OauthTokenResponse + fun fetchMemberInfo(accessToken: String): KakaoMemberResponse } diff --git a/src/main/kotlin/com/vacgom/backend/domain/auth/AuthUriGenerator.kt b/src/main/kotlin/com/vacgom/backend/domain/auth/AuthUriGenerator.kt index f49a0f6..d04b30a 100644 --- a/src/main/kotlin/com/vacgom/backend/domain/auth/AuthUriGenerator.kt +++ b/src/main/kotlin/com/vacgom/backend/domain/auth/AuthUriGenerator.kt @@ -1,6 +1,6 @@ package com.vacgom.backend.domain.auth -import com.vacgom.backend.domain.member.constants.ProviderType +import com.vacgom.backend.domain.auth.constants.ProviderType import java.net.URI interface AuthUriGenerator { diff --git a/src/main/kotlin/com/vacgom/backend/domain/member/RefreshToken.kt b/src/main/kotlin/com/vacgom/backend/domain/auth/RefreshToken.kt similarity index 83% rename from src/main/kotlin/com/vacgom/backend/domain/member/RefreshToken.kt rename to src/main/kotlin/com/vacgom/backend/domain/auth/RefreshToken.kt index 5f67f8e..31e9637 100644 --- a/src/main/kotlin/com/vacgom/backend/domain/member/RefreshToken.kt +++ b/src/main/kotlin/com/vacgom/backend/domain/auth/RefreshToken.kt @@ -1,5 +1,6 @@ -package com.vacgom.backend.domain.member +package com.vacgom.backend.domain.auth +import com.vacgom.backend.domain.member.Member import jakarta.persistence.* import java.time.LocalDateTime diff --git a/src/main/kotlin/com/vacgom/backend/domain/member/constants/ProviderType.kt b/src/main/kotlin/com/vacgom/backend/domain/auth/constants/ProviderType.kt similarity index 90% rename from src/main/kotlin/com/vacgom/backend/domain/member/constants/ProviderType.kt rename to src/main/kotlin/com/vacgom/backend/domain/auth/constants/ProviderType.kt index 11abd42..e78cd1d 100644 --- a/src/main/kotlin/com/vacgom/backend/domain/member/constants/ProviderType.kt +++ b/src/main/kotlin/com/vacgom/backend/domain/auth/constants/ProviderType.kt @@ -1,4 +1,4 @@ -package com.vacgom.backend.domain.member.constants +package com.vacgom.backend.domain.auth.constants import com.vacgom.backend.global.exception.error.BusinessException import com.vacgom.backend.global.security.exception.AuthError diff --git a/src/main/kotlin/com/vacgom/backend/domain/member/constants/Role.kt b/src/main/kotlin/com/vacgom/backend/domain/auth/constants/Role.kt similarity index 51% rename from src/main/kotlin/com/vacgom/backend/domain/member/constants/Role.kt rename to src/main/kotlin/com/vacgom/backend/domain/auth/constants/Role.kt index 3224218..c971e28 100644 --- a/src/main/kotlin/com/vacgom/backend/domain/member/constants/Role.kt +++ b/src/main/kotlin/com/vacgom/backend/domain/auth/constants/Role.kt @@ -1,4 +1,4 @@ -package com.vacgom.backend.domain.member.constants +package com.vacgom.backend.domain.auth.constants enum class Role { ROLE_TEMP_USER, diff --git a/src/main/kotlin/com/vacgom/backend/domain/member/Member.kt b/src/main/kotlin/com/vacgom/backend/domain/member/Member.kt index 3ddd7b2..9034eee 100644 --- a/src/main/kotlin/com/vacgom/backend/domain/member/Member.kt +++ b/src/main/kotlin/com/vacgom/backend/domain/member/Member.kt @@ -1,7 +1,7 @@ package com.vacgom.backend.domain.member -import com.vacgom.backend.domain.member.constants.ProviderType -import com.vacgom.backend.domain.member.constants.Role +import com.vacgom.backend.domain.auth.constants.ProviderType +import com.vacgom.backend.domain.auth.constants.Role import com.vacgom.backend.global.auditing.BaseEntity import jakarta.persistence.* import org.hibernate.annotations.GenericGenerator @@ -20,6 +20,6 @@ class Member( @GenericGenerator(name = "uuid2", strategy = "uuid2") @Column(columnDefinition = "BINARY(16)", name = "member_id") var id: UUID? = null - + var name: String? = null } diff --git a/src/main/kotlin/com/vacgom/backend/infrastructure/auth/kakao/KakaoAuthConnector.kt b/src/main/kotlin/com/vacgom/backend/infrastructure/auth/kakao/KakaoAuthConnector.kt index ef7f9e6..053123f 100644 --- a/src/main/kotlin/com/vacgom/backend/infrastructure/auth/kakao/KakaoAuthConnector.kt +++ b/src/main/kotlin/com/vacgom/backend/infrastructure/auth/kakao/KakaoAuthConnector.kt @@ -1,12 +1,12 @@ package com.vacgom.backend.infrastructure.auth.kakao -import com.vacgom.backend.application.auth.dto.OauthToken -import com.vacgom.backend.application.auth.property.KakaoProperties +import com.vacgom.backend.application.auth.dto.KakaoMemberResponse +import com.vacgom.backend.application.auth.dto.OauthTokenResponse import com.vacgom.backend.domain.auth.AuthConnector -import com.vacgom.backend.domain.member.constants.ProviderType +import com.vacgom.backend.domain.auth.constants.ProviderType import com.vacgom.backend.global.exception.error.BusinessException import com.vacgom.backend.global.security.exception.AuthError -import com.vacgom.backend.infrastructure.auth.kakao.model.KakaoMemberInfo +import com.vacgom.backend.infrastructure.auth.kakao.model.KakaoProperties import org.springframework.http.HttpEntity import org.springframework.http.HttpHeaders import org.springframework.http.HttpMethod @@ -26,7 +26,7 @@ class KakaoAuthConnector( return provider.isKakao() } - override fun fetchOauthToken(code: String): OauthToken { + override fun fetchOauthToken(code: String): OauthTokenResponse { val headers = createHttpHeaders() val body: MultiValueMap = LinkedMultiValueMap() @@ -41,14 +41,14 @@ class KakaoAuthConnector( restTemplate.postForObject( kakaoProperties.tokenEndpoint!!, request, - OauthToken::class.java + OauthTokenResponse::class.java )!! } catch (exception: RestClientException) { throw BusinessException(AuthError.KAKAO_OAUTH_ERROR) } } - override fun fetchMemberInfo(accessToken: String): KakaoMemberInfo { + override fun fetchMemberInfo(accessToken: String): KakaoMemberResponse { val headers = createHttpHeaders() headers.set("Authorization", "Bearer $accessToken") @@ -58,7 +58,7 @@ class KakaoAuthConnector( kakaoProperties.userinfoEndpoint!!, HttpMethod.GET, request, - KakaoMemberInfo::class.java + KakaoMemberResponse::class.java ).body ?: throw BusinessException(AuthError.KAKAO_OAUTH_ERROR) } catch (exception: RestClientException) { println("e = ${exception}") diff --git a/src/main/kotlin/com/vacgom/backend/infrastructure/auth/kakao/KakaoUriGenerator.kt b/src/main/kotlin/com/vacgom/backend/infrastructure/auth/kakao/KakaoUriGenerator.kt index 9e225c4..7a304af 100644 --- a/src/main/kotlin/com/vacgom/backend/infrastructure/auth/kakao/KakaoUriGenerator.kt +++ b/src/main/kotlin/com/vacgom/backend/infrastructure/auth/kakao/KakaoUriGenerator.kt @@ -1,8 +1,8 @@ package com.vacgom.backend.infrastructure.auth.kakao -import com.vacgom.backend.application.auth.property.KakaoProperties import com.vacgom.backend.domain.auth.AuthUriGenerator -import com.vacgom.backend.domain.member.constants.ProviderType +import com.vacgom.backend.domain.auth.constants.ProviderType +import com.vacgom.backend.infrastructure.auth.kakao.model.KakaoProperties import org.springframework.stereotype.Component import org.springframework.web.util.UriComponentsBuilder import java.net.URI diff --git a/src/main/kotlin/com/vacgom/backend/infrastructure/auth/kakao/model/KakaoMemberInfo.kt b/src/main/kotlin/com/vacgom/backend/infrastructure/auth/kakao/model/KakaoMemberInfo.kt deleted file mode 100644 index 56c983c..0000000 --- a/src/main/kotlin/com/vacgom/backend/infrastructure/auth/kakao/model/KakaoMemberInfo.kt +++ /dev/null @@ -1,5 +0,0 @@ -package com.vacgom.backend.infrastructure.auth.kakao.model - -data class KakaoMemberInfo( - var id: Long -) diff --git a/src/main/kotlin/com/vacgom/backend/application/auth/property/KakaoProperties.kt b/src/main/kotlin/com/vacgom/backend/infrastructure/auth/kakao/model/KakaoProperties.kt similarity index 93% rename from src/main/kotlin/com/vacgom/backend/application/auth/property/KakaoProperties.kt rename to src/main/kotlin/com/vacgom/backend/infrastructure/auth/kakao/model/KakaoProperties.kt index 8d59dca..8ab0827 100644 --- a/src/main/kotlin/com/vacgom/backend/application/auth/property/KakaoProperties.kt +++ b/src/main/kotlin/com/vacgom/backend/infrastructure/auth/kakao/model/KakaoProperties.kt @@ -1,4 +1,4 @@ -package com.vacgom.backend.application.auth.property +package com.vacgom.backend.infrastructure.auth.kakao.model import org.springframework.beans.factory.annotation.Value import org.springframework.stereotype.Component diff --git a/src/main/kotlin/com/vacgom/backend/infrastructure/member/RefreshTokenRepository.kt b/src/main/kotlin/com/vacgom/backend/infrastructure/auth/persistence/RefreshTokenRepository.kt similarity index 57% rename from src/main/kotlin/com/vacgom/backend/infrastructure/member/RefreshTokenRepository.kt rename to src/main/kotlin/com/vacgom/backend/infrastructure/auth/persistence/RefreshTokenRepository.kt index 2865059..95f2aec 100644 --- a/src/main/kotlin/com/vacgom/backend/infrastructure/member/RefreshTokenRepository.kt +++ b/src/main/kotlin/com/vacgom/backend/infrastructure/auth/persistence/RefreshTokenRepository.kt @@ -1,6 +1,6 @@ -package com.vacgom.backend.infrastructure.member +package com.vacgom.backend.infrastructure.auth.persistence -import com.vacgom.backend.domain.member.RefreshToken +import com.vacgom.backend.domain.auth.RefreshToken import org.springframework.data.jpa.repository.JpaRepository import java.util.* diff --git a/src/main/kotlin/com/vacgom/backend/infrastructure/member/MemberRepository.kt b/src/main/kotlin/com/vacgom/backend/infrastructure/member/persistence/MemberRepository.kt similarity index 72% rename from src/main/kotlin/com/vacgom/backend/infrastructure/member/MemberRepository.kt rename to src/main/kotlin/com/vacgom/backend/infrastructure/member/persistence/MemberRepository.kt index bbdeedc..b79281b 100644 --- a/src/main/kotlin/com/vacgom/backend/infrastructure/member/MemberRepository.kt +++ b/src/main/kotlin/com/vacgom/backend/infrastructure/member/persistence/MemberRepository.kt @@ -1,7 +1,7 @@ -package com.vacgom.backend.infrastructure.member +package com.vacgom.backend.infrastructure.member.persistence +import com.vacgom.backend.domain.auth.constants.ProviderType import com.vacgom.backend.domain.member.Member -import com.vacgom.backend.domain.member.constants.ProviderType import org.springframework.data.jpa.repository.JpaRepository import java.util.*