generated from pricelees/issue-pr-template
[#68] ArgumentResolver에서의 불필요한 DB 요청 로직 제거 #69
@ -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}" }
|
||||
|
||||
@ -43,16 +43,6 @@ class PaymentAPITest(
|
||||
expectedErrorCode = AuthErrorCode.MEMBER_NOT_FOUND
|
||||
)
|
||||
}
|
||||
|
||||
test("관리자") {
|
||||
runExceptionTest(
|
||||
token = testAuthUtil.defaultHqAdminLogin().second,
|
||||
method = HttpMethod.POST,
|
||||
endpoint = endpoint,
|
||||
requestBody = PaymentFixture.cancelRequest,
|
||||
expectedErrorCode = AuthErrorCode.MEMBER_NOT_FOUND
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
test("정상 취소") {
|
||||
|
||||
@ -49,15 +49,6 @@ class ReservationApiTest(
|
||||
expectedErrorCode = AuthErrorCode.MEMBER_NOT_FOUND
|
||||
)
|
||||
}
|
||||
|
||||
test("관리자") {
|
||||
runExceptionTest(
|
||||
token = testAuthUtil.defaultHqAdminLogin().second,
|
||||
method = HttpMethod.POST,
|
||||
endpoint = endpoint,
|
||||
expectedErrorCode = AuthErrorCode.MEMBER_NOT_FOUND
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -185,15 +176,6 @@ class ReservationApiTest(
|
||||
expectedErrorCode = AuthErrorCode.TOKEN_NOT_FOUND
|
||||
)
|
||||
}
|
||||
|
||||
test("관리자") {
|
||||
runExceptionTest(
|
||||
token = testAuthUtil.defaultHqAdminLogin().second,
|
||||
method = HttpMethod.POST,
|
||||
endpoint = endpoint,
|
||||
expectedErrorCode = AuthErrorCode.ACCESS_DENIED
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
test("정상 응답") {
|
||||
@ -238,15 +220,6 @@ class ReservationApiTest(
|
||||
expectedErrorCode = AuthErrorCode.TOKEN_NOT_FOUND
|
||||
)
|
||||
}
|
||||
|
||||
test("관리자") {
|
||||
runExceptionTest(
|
||||
token = testAuthUtil.defaultHqAdminLogin().second,
|
||||
method = HttpMethod.POST,
|
||||
endpoint = endpoint,
|
||||
expectedErrorCode = AuthErrorCode.ACCESS_DENIED
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
test("정상 응답") {
|
||||
@ -315,15 +288,6 @@ class ReservationApiTest(
|
||||
expectedErrorCode = AuthErrorCode.TOKEN_NOT_FOUND
|
||||
)
|
||||
}
|
||||
|
||||
test("관리자") {
|
||||
runExceptionTest(
|
||||
token = testAuthUtil.defaultHqAdminLogin().second,
|
||||
method = HttpMethod.POST,
|
||||
endpoint = endpoint,
|
||||
expectedErrorCode = AuthErrorCode.ACCESS_DENIED
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
test("정상 응답") {
|
||||
@ -377,15 +341,6 @@ class ReservationApiTest(
|
||||
expectedErrorCode = AuthErrorCode.TOKEN_NOT_FOUND
|
||||
)
|
||||
}
|
||||
|
||||
test("관리자") {
|
||||
runExceptionTest(
|
||||
token = testAuthUtil.defaultHqAdminLogin().second,
|
||||
method = HttpMethod.POST,
|
||||
endpoint = endpoint,
|
||||
expectedErrorCode = AuthErrorCode.ACCESS_DENIED
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
context("정상 응답") {
|
||||
|
||||
@ -108,7 +108,7 @@ class ReservationConcurrencyTest(
|
||||
|
||||
private fun createPendingReservation(user: UserEntity, schedule: ScheduleEntity): Long {
|
||||
return reservationService.createPendingReservation(
|
||||
user = CurrentUserContext(id = user.id, name = user.name),
|
||||
user = CurrentUserContext(id = user.id),
|
||||
request = PendingReservationCreateRequest(
|
||||
scheduleId = schedule.id,
|
||||
reserverName = user.name,
|
||||
|
||||
@ -148,15 +148,6 @@ class UserApiTest(
|
||||
expectedErrorCode = AuthErrorCode.MEMBER_NOT_FOUND
|
||||
)
|
||||
}
|
||||
|
||||
test("관리자") {
|
||||
runExceptionTest(
|
||||
token = testAuthUtil.defaultStoreAdminLogin().second,
|
||||
method = HttpMethod.GET,
|
||||
endpoint = endpoint,
|
||||
expectedErrorCode = AuthErrorCode.MEMBER_NOT_FOUND
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
test("정상 응답") {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user