Skip to content

Commit

Permalink
feat : 유저 정보(닉네임) 조회 API (#132)
Browse files Browse the repository at this point in the history
  • Loading branch information
dlswns2480 authored Aug 24, 2024
1 parent 2574cb2 commit 5dd7385
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 1 deletion.
10 changes: 10 additions & 0 deletions adapters/in-web/src/main/kotlin/com/pokit/user/UserController.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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<UserResponse> {
return userUseCase.getUserInfo(user.id)
.toResponse()
.wrapOk()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,6 @@ interface UserUseCase {
fun fetchAllUserId(): List<Long>

fun createFcmToken(userId: Long, request: CreateFcmTokenRequest): FcmToken

fun getUserInfo(userId: Long): User
}
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -21,7 +22,8 @@ class UserServiceTest : BehaviorSpec({
val userPort = mockk<UserPort>()
val categoryPort = mockk<CategoryPort>()
val categoryImagePort = mockk<CategoryImagePort>()
val userService = UserService(userPort, categoryPort, categoryImagePort)
val fcmTokenPort = mockk<FcmTokenPort>()
val userService = UserService(userPort, categoryPort, categoryImagePort, fcmTokenPort)
Given("회원을 등록할 때") {
val user = UserFixture.getUser()
val invalidUser = UserFixture.getInvalidUser()
Expand Down

0 comments on commit 5dd7385

Please sign in to comment.