Skip to content

Commit

Permalink
chore: 패키지 구조 개선
Browse files Browse the repository at this point in the history
  • Loading branch information
h-beeen committed Mar 16, 2024
1 parent 266069d commit b88fc88
Show file tree
Hide file tree
Showing 18 changed files with 45 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.vacgom.backend.application.auth.dto

data class KakaoMemberResponse(
var id: Long
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.vacgom.backend.application.auth.dto

data class LoginResponse(
val member: MemberResponse,
val token: TokenResponse
)
Original file line number Diff line number Diff line change
@@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
10 changes: 5 additions & 5 deletions src/main/kotlin/com/vacgom/backend/domain/auth/AuthConnector.kt
Original file line number Diff line number Diff line change
@@ -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
}
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
Original file line number Diff line number Diff line change
@@ -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

Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.vacgom.backend.domain.member.constants
package com.vacgom.backend.domain.auth.constants

enum class Role {
ROLE_TEMP_USER,
Expand Down
6 changes: 3 additions & 3 deletions src/main/kotlin/com/vacgom/backend/domain/member/Member.kt
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
}
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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<String, String> = LinkedMultiValueMap()

Expand All @@ -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")

Expand All @@ -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}")
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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.*

Expand Down
Original file line number Diff line number Diff line change
@@ -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.*

Expand Down

0 comments on commit b88fc88

Please sign in to comment.