diff --git a/adapters/in-web/src/main/kotlin/com/pokit/user/UserController.kt b/adapters/in-web/src/main/kotlin/com/pokit/user/UserController.kt index d3a89eed..257c7a47 100644 --- a/adapters/in-web/src/main/kotlin/com/pokit/user/UserController.kt +++ b/adapters/in-web/src/main/kotlin/com/pokit/user/UserController.kt @@ -80,4 +80,14 @@ class UserController( return userUseCase.createFcmToken(user.id, request.toDto()) .wrapOk() } + + @GetMapping("/nickname") + @Operation(summary = "유저 정보(닉네임) 조회 API") + fun getUserInfo( + @AuthenticationPrincipal user: PrincipalUser + ): ResponseEntity { + return userUseCase.getUserInfo(user.id) + .toResponse() + .wrapOk() + } } diff --git a/application/src/main/kotlin/com/pokit/user/port/in/UserUseCase.kt b/application/src/main/kotlin/com/pokit/user/port/in/UserUseCase.kt index 879afc12..347b2c2d 100644 --- a/application/src/main/kotlin/com/pokit/user/port/in/UserUseCase.kt +++ b/application/src/main/kotlin/com/pokit/user/port/in/UserUseCase.kt @@ -16,4 +16,6 @@ interface UserUseCase { fun fetchAllUserId(): List fun createFcmToken(userId: Long, request: CreateFcmTokenRequest): FcmToken + + fun getUserInfo(userId: Long): User } diff --git a/application/src/main/kotlin/com/pokit/user/port/service/UserService.kt b/application/src/main/kotlin/com/pokit/user/port/service/UserService.kt index 3fa308da..8c0d3cd3 100644 --- a/application/src/main/kotlin/com/pokit/user/port/service/UserService.kt +++ b/application/src/main/kotlin/com/pokit/user/port/service/UserService.kt @@ -87,4 +87,9 @@ class UserService( val fcmToken = FcmToken(user.id, request.token) return fcmTokenPort.persist(fcmToken) } + + override fun getUserInfo(userId: Long): User { + return userPort.loadById(userId) + ?: throw NotFoundCustomException(UserErrorCode.NOT_FOUND_USER) + } } diff --git a/application/src/test/kotlin/com/pokit/user/port/service/UserServiceTest.kt b/application/src/test/kotlin/com/pokit/user/port/service/UserServiceTest.kt index 6e5f506b..6efb981c 100644 --- a/application/src/test/kotlin/com/pokit/user/port/service/UserServiceTest.kt +++ b/application/src/test/kotlin/com/pokit/user/port/service/UserServiceTest.kt @@ -10,6 +10,7 @@ import com.pokit.token.model.AuthPlatform import com.pokit.user.UserFixture import com.pokit.user.dto.request.UpdateNicknameRequest import com.pokit.user.model.User +import com.pokit.user.port.out.FcmTokenPort import com.pokit.user.port.out.UserPort import io.kotest.assertions.throwables.shouldThrow import io.kotest.core.spec.style.BehaviorSpec @@ -21,7 +22,8 @@ class UserServiceTest : BehaviorSpec({ val userPort = mockk() val categoryPort = mockk() val categoryImagePort = mockk() - val userService = UserService(userPort, categoryPort, categoryImagePort) + val fcmTokenPort = mockk() + val userService = UserService(userPort, categoryPort, categoryImagePort, fcmTokenPort) Given("회원을 등록할 때") { val user = UserFixture.getUser() val invalidUser = UserFixture.getInvalidUser()