diff --git a/src/main/kotlin/scul/projectscul/domain/user/presentation/UserController.kt b/src/main/kotlin/scul/projectscul/domain/user/presentation/UserController.kt index 0649f27..3e690e7 100644 --- a/src/main/kotlin/scul/projectscul/domain/user/presentation/UserController.kt +++ b/src/main/kotlin/scul/projectscul/domain/user/presentation/UserController.kt @@ -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 @@ -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 { @@ -25,4 +29,9 @@ class UserController ( fun login(@RequestBody request: LoginRequest) : TokenResponse { return loginService.execute(request) } + + @GetMapping("/name") + fun getMyName(): GetMyNameResponse { + return getMyNameService.execute() + } } diff --git a/src/main/kotlin/scul/projectscul/domain/user/presentation/response/GetMyNameResponse.kt b/src/main/kotlin/scul/projectscul/domain/user/presentation/response/GetMyNameResponse.kt new file mode 100644 index 0000000..3466f97 --- /dev/null +++ b/src/main/kotlin/scul/projectscul/domain/user/presentation/response/GetMyNameResponse.kt @@ -0,0 +1,5 @@ +package scul.projectscul.domain.user.presentation.response + +data class GetMyNameResponse ( + val name: String +) \ No newline at end of file diff --git a/src/main/kotlin/scul/projectscul/domain/user/service/GetMyNameService.kt b/src/main/kotlin/scul/projectscul/domain/user/service/GetMyNameService.kt new file mode 100644 index 0000000..53fca96 --- /dev/null +++ b/src/main/kotlin/scul/projectscul/domain/user/service/GetMyNameService.kt @@ -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) + } +} \ No newline at end of file