From 5b48dbe8df151827afdfde0320c951a63a29e8cb Mon Sep 17 00:00:00 2001 From: San Kim Date: Tue, 26 Nov 2024 08:18:48 +0900 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20=EC=9D=B4=EC=83=81=ED=98=95=20?= =?UTF-8?q?=ED=94=84=EB=A1=9C=ED=95=84=20=EC=88=98=EC=A0=95=20API=20?= =?UTF-8?q?=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../user/port/inbound/UpdateDesiredPartner.kt | 1 - .../bootstrap/api/user/UserController.kt | 47 +++++++++++++++++-- openapi | 2 +- 3 files changed, 44 insertions(+), 6 deletions(-) diff --git a/application/src/main/kotlin/com/threedays/application/user/port/inbound/UpdateDesiredPartner.kt b/application/src/main/kotlin/com/threedays/application/user/port/inbound/UpdateDesiredPartner.kt index 652a14e..9d73fc1 100644 --- a/application/src/main/kotlin/com/threedays/application/user/port/inbound/UpdateDesiredPartner.kt +++ b/application/src/main/kotlin/com/threedays/application/user/port/inbound/UpdateDesiredPartner.kt @@ -14,7 +14,6 @@ interface UpdateDesiredPartner { val birthYearRange: BirthYearRange, val jobOccupations: List, val preferDistance: UserDesiredPartner.PreferDistance, - val allowSameCompany: Boolean?, ) } diff --git a/bootstrap/api/src/main/kotlin/com/threedays/bootstrap/api/user/UserController.kt b/bootstrap/api/src/main/kotlin/com/threedays/bootstrap/api/user/UserController.kt index 7e311cc..1d13f20 100644 --- a/bootstrap/api/src/main/kotlin/com/threedays/bootstrap/api/user/UserController.kt +++ b/bootstrap/api/src/main/kotlin/com/threedays/bootstrap/api/user/UserController.kt @@ -3,6 +3,7 @@ package com.threedays.bootstrap.api.user import com.threedays.application.user.port.inbound.DeleteProfileWidget import com.threedays.application.user.port.inbound.PutProfileWidget import com.threedays.application.user.port.inbound.RegisterUser +import com.threedays.application.user.port.inbound.UpdateDesiredPartner import com.threedays.application.user.port.inbound.UpdateUserInfo import com.threedays.bootstrap.api.support.security.UserAuthentication import com.threedays.bootstrap.api.support.security.withUserAuthentication @@ -17,12 +18,16 @@ import com.threedays.oas.api.UsersApi import com.threedays.oas.model.CompanyDisplayInfo import com.threedays.oas.model.GetMyUserInfoResponse import com.threedays.oas.model.JobOccupationDisplayInfo +import com.threedays.oas.model.LocationDisplayInfo +import com.threedays.oas.model.PreferDistance import com.threedays.oas.model.ProfileWidget import com.threedays.oas.model.ProfileWidgetType import com.threedays.oas.model.RegisterUserRequest import com.threedays.oas.model.TokenResponse import com.threedays.oas.model.UpdateMyUserInfoRequest import com.threedays.oas.model.UpdateMyUserInfoResponse +import com.threedays.oas.model.UpdateUserDesiredPartnerRequest +import com.threedays.oas.model.UpdateUserDesiredPartnerResponse import com.threedays.oas.model.UserProfile import com.threedays.oas.model.UserProfileDisplayInfo import com.threedays.support.common.base.domain.UUIDTypeId @@ -39,6 +44,7 @@ class UserController( private val userRepository: UserRepository, private val deleteProfileWidget: DeleteProfileWidget, private val updateUserInfo: UpdateUserInfo, + private val updateDesiredPartner: UpdateDesiredPartner, ) : UsersApi { override fun registerUser( @@ -99,7 +105,7 @@ class UserController( display = "test" ), locations = user.profile.locations.map { - com.threedays.oas.model.LocationDisplayInfo( + LocationDisplayInfo( id = it.id.value, display = it.display, ) @@ -123,11 +129,11 @@ class UserController( it.end?.value, ) }, - preferDistance = com.threedays.oas.model.PreferDistance.valueOf(user.desiredPartner.preferDistance.name), + preferDistance = PreferDistance.valueOf(user.desiredPartner.preferDistance.name), ), profileWidgets = user.profile.profileWidgets.map { ProfileWidget( - type = com.threedays.oas.model.ProfileWidgetType.valueOf(it.type.name), + type = ProfileWidgetType.valueOf(it.type.name), content = it.content, ) } @@ -201,9 +207,42 @@ class UserController( it.end?.value, ) }, - preferDistance = com.threedays.oas.model.PreferDistance.valueOf(user.desiredPartner.preferDistance.name), + preferDistance = PreferDistance.valueOf(user.desiredPartner.preferDistance.name), ) ).let { ResponseEntity.ok(it) } } + override fun updateMyDesiredPartner(updateUserDesiredPartnerRequest: UpdateUserDesiredPartnerRequest): ResponseEntity = withUserAuthentication { authentication -> + val command = UpdateDesiredPartner.Command( + userId = authentication.userId, + jobOccupations = updateUserDesiredPartnerRequest.jobOccupations.map { + JobOccupation.valueOf(it.name) + }, + birthYearRange = updateUserDesiredPartnerRequest.birthYearRange.let { + BirthYearRange( + start = it.start?.let { Year.of(it) }, + end = it.end?.let { Year.of(it) } + ) + }, + preferDistance = UserDesiredPartner.PreferDistance.valueOf(updateUserDesiredPartnerRequest.preferDistance.name), + ) + + val user: User = updateDesiredPartner.invoke(command) + + UpdateUserDesiredPartnerResponse( + desiredPartner = com.threedays.oas.model.UserDesiredPartner( + birthYearRange = user.desiredPartner.birthYearRange.let { + com.threedays.oas.model.BirthYearRange( + it.start?.value, + it.end?.value, + ) + }, + jobOccupations = user.desiredPartner.jobOccupations.map { + com.threedays.oas.model.JobOccupation.valueOf(it.name) + }, + preferDistance = PreferDistance.valueOf(user.desiredPartner.preferDistance.name), + ) + ).let { ResponseEntity.ok(it) } + + } } diff --git a/openapi b/openapi index fc5b0be..59a761e 160000 --- a/openapi +++ b/openapi @@ -1 +1 @@ -Subproject commit fc5b0be00620e28dfb13946e709dec968b4e9553 +Subproject commit 59a761ea043af65e69cfc6100500b6359381f14d