diff --git a/src/main/kotlin/org/meogo/domain/review/service/QueryAllBySchoolIdService.kt b/src/main/kotlin/org/meogo/domain/review/service/QueryAllBySchoolIdService.kt index 389d692..1ee008a 100644 --- a/src/main/kotlin/org/meogo/domain/review/service/QueryAllBySchoolIdService.kt +++ b/src/main/kotlin/org/meogo/domain/review/service/QueryAllBySchoolIdService.kt @@ -3,6 +3,7 @@ package org.meogo.domain.review.service import org.meogo.domain.review.domain.ReviewRepository import org.meogo.domain.review.presentation.dto.response.ReviewListResponse import org.meogo.domain.review.presentation.dto.response.ReviewResponse +import org.meogo.domain.user.exception.UserNotFoundException import org.meogo.domain.user.facade.UserFacade import org.meogo.global.s3.FileUtil import org.meogo.global.s3.Path @@ -23,7 +24,7 @@ class QueryAllBySchoolIdService( return ReviewListResponse( count = reviews.size, reviews = reviews.map { review -> - val user = userFacade.getUserById(review.userId) + val user = userFacade.getUserById(review.userId) ?: throw UserNotFoundException val profile = fileUtil.generateObjectUrl(user.profile, Path.USER) val image = review.picture?.split(",")?.map { pic -> fileUtil.generateObjectUrl(pic.trim(), Path.REVIEW) diff --git a/src/main/kotlin/org/meogo/domain/user/facade/UserFacade.kt b/src/main/kotlin/org/meogo/domain/user/facade/UserFacade.kt index cc8c830..3d5019b 100644 --- a/src/main/kotlin/org/meogo/domain/user/facade/UserFacade.kt +++ b/src/main/kotlin/org/meogo/domain/user/facade/UserFacade.kt @@ -16,9 +16,9 @@ class UserFacade( return accountId?.let { getUserByAccountId(it) } } - fun getUserByAccountId(accountId: String): User = + fun getUserByAccountId(accountId: String): User? = userRepository.findByAccountId(accountId) - fun getUserById(id: UUID): User = + fun getUserById(id: UUID): User? = userRepository.findById(id) } diff --git a/src/main/kotlin/org/meogo/global/auth/AuthDetailsService.kt b/src/main/kotlin/org/meogo/global/auth/AuthDetailsService.kt index 3a357af..3eadb0f 100644 --- a/src/main/kotlin/org/meogo/global/auth/AuthDetailsService.kt +++ b/src/main/kotlin/org/meogo/global/auth/AuthDetailsService.kt @@ -1,5 +1,6 @@ package org.meogo.global.auth +import org.meogo.domain.user.exception.UserNotFoundException import org.meogo.domain.user.facade.UserFacade import org.springframework.security.core.userdetails.UserDetails import org.springframework.security.core.userdetails.UserDetailsService @@ -10,7 +11,7 @@ class AuthDetailsService( private val userFacade: UserFacade ) : UserDetailsService { override fun loadUserByUsername(username: String): UserDetails { - val user = userFacade.getUserByAccountId(username) + val user = userFacade.getUserByAccountId(username) ?: throw UserNotFoundException return AuthDetails(user.accountId, user.role) } }