generated from pricelees/issue-pr-template
refactor: UserContextResolver에서의 DB 조회 로직 제거
This commit is contained in:
parent
06f7faf7f9
commit
ce75ceb0ca
@ -6,7 +6,7 @@ import com.sangdol.roomescape.auth.exception.AuthException
|
||||
import com.sangdol.roomescape.auth.infrastructure.jwt.JwtUtils
|
||||
import com.sangdol.roomescape.auth.web.support.User
|
||||
import com.sangdol.roomescape.auth.web.support.accessToken
|
||||
import com.sangdol.roomescape.user.business.UserService
|
||||
import com.sangdol.roomescape.common.types.CurrentUserContext
|
||||
import io.github.oshai.kotlinlogging.KLogger
|
||||
import io.github.oshai.kotlinlogging.KotlinLogging
|
||||
import jakarta.servlet.http.HttpServletRequest
|
||||
@ -22,7 +22,6 @@ private val log: KLogger = KotlinLogging.logger {}
|
||||
@Component
|
||||
class UserContextResolver(
|
||||
private val jwtUtils: JwtUtils,
|
||||
private val userService: UserService,
|
||||
) : HandlerMethodArgumentResolver {
|
||||
|
||||
override fun supportsParameter(parameter: MethodParameter): Boolean {
|
||||
@ -43,7 +42,7 @@ class UserContextResolver(
|
||||
MdcPrincipalIdUtil.set(it)
|
||||
}.toLong()
|
||||
|
||||
return userService.findContextById(id)
|
||||
return CurrentUserContext(id = id)
|
||||
} catch (e: Exception) {
|
||||
log.info { "[UserContextResolver] 회원 조회 실패. message=${e.message}" }
|
||||
throw AuthException(AuthErrorCode.MEMBER_NOT_FOUND)
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
package com.sangdol.roomescape.common.types
|
||||
|
||||
data class CurrentUserContext(
|
||||
val id: Long,
|
||||
val name: String,
|
||||
val id: Long
|
||||
)
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
package com.sangdol.roomescape.user.business
|
||||
|
||||
import com.sangdol.common.persistence.IDGenerator
|
||||
import com.sangdol.roomescape.common.types.CurrentUserContext
|
||||
import com.sangdol.roomescape.user.dto.UserContactResponse
|
||||
import com.sangdol.roomescape.user.dto.UserCreateRequest
|
||||
import com.sangdol.roomescape.user.dto.UserCreateResponse
|
||||
@ -28,17 +27,6 @@ class UserService(
|
||||
private val userValidator: UserValidator,
|
||||
private val idGenerator: IDGenerator
|
||||
) {
|
||||
@Transactional(readOnly = true)
|
||||
fun findContextById(id: Long): CurrentUserContext {
|
||||
log.info { "[findContextById] 현재 로그인된 회원 조회 시작: id=${id}" }
|
||||
val user: UserEntity = findOrThrow(id)
|
||||
|
||||
return CurrentUserContext(user.id, user.name)
|
||||
.also {
|
||||
log.info { "[findContextById] 현재 로그인된 회원 조회 완료: id=${id}" }
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional(readOnly = true)
|
||||
fun findCredentialsByAccount(email: String): UserLoginCredentials {
|
||||
log.info { "[findCredentialsByAccount] 회원 조회 시작: email=${email}" }
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user