Skip to content

Commit

Permalink
🧩 :: 내 이름 조회 api 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
ilyoil2 committed May 7, 2024
1 parent 705d95b commit fa993e9
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package scul.projectscul.domain.user.presentation

import org.springframework.web.bind.annotation.GetMapping
import scul.projectscul.global.security.dto.response.TokenResponse
import scul.projectscul.domain.user.presentation.request.SignUpRequest
import scul.projectscul.domain.user.service.SignUpService
Expand All @@ -8,13 +9,16 @@ import org.springframework.web.bind.annotation.RequestBody
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController
import scul.projectscul.domain.user.presentation.request.LoginRequest
import scul.projectscul.domain.user.presentation.response.GetMyNameResponse
import scul.projectscul.domain.user.service.GetMyNameService
import scul.projectscul.domain.user.service.LoginService

@RequestMapping("/scul/users")
@RestController
class UserController (
private val signUpService: SignUpService,
private val loginService: LoginService
private val loginService: LoginService,
private val getMyNameService: GetMyNameService
) {
@PostMapping("/signup")
fun signUp(@RequestBody request: SignUpRequest) : TokenResponse {
Expand All @@ -25,4 +29,9 @@ class UserController (
fun login(@RequestBody request: LoginRequest) : TokenResponse {
return loginService.execute(request)
}

@GetMapping("/name")
fun getMyName(): GetMyNameResponse {
return getMyNameService.execute()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package scul.projectscul.domain.user.presentation.response

data class GetMyNameResponse (
val name: String
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package scul.projectscul.domain.user.service

import org.springframework.stereotype.Service
import org.springframework.transaction.annotation.Transactional
import scul.projectscul.domain.user.domain.repository.UserRepository
import scul.projectscul.domain.user.facade.UserFacade
import scul.projectscul.domain.user.presentation.response.GetMyNameResponse

@Service
@Transactional(readOnly = true)
class GetMyNameService (
private val userFacade: UserFacade
) {
fun execute(): GetMyNameResponse {
val currentUser = userFacade.getCurrentUser()

return GetMyNameResponse(currentUser.name)
}
}

0 comments on commit fa993e9

Please sign in to comment.