From fa993e96ab43589222b571381be34256a69b0760 Mon Sep 17 00:00:00 2001 From: "tae.y" <0211ilyoil@gmail.com> Date: Tue, 7 May 2024 12:27:01 +0900 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=A9=20::=20=EB=82=B4=20=EC=9D=B4?= =?UTF-8?q?=EB=A6=84=20=EC=A1=B0=ED=9A=8C=20api=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../user/presentation/UserController.kt | 11 ++++++++++- .../response/GetMyNameResponse.kt | 5 +++++ .../domain/user/service/GetMyNameService.kt | 19 +++++++++++++++++++ 3 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 src/main/kotlin/scul/projectscul/domain/user/presentation/response/GetMyNameResponse.kt create mode 100644 src/main/kotlin/scul/projectscul/domain/user/service/GetMyNameService.kt 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