diff --git a/src/main/kotlin/andreas311/miso/domain/user/adapter/input/UserAdapter.kt b/src/main/kotlin/andreas311/miso/domain/user/adapter/input/UserAdapter.kt index 19184897..300c8f0b 100644 --- a/src/main/kotlin/andreas311/miso/domain/user/adapter/input/UserAdapter.kt +++ b/src/main/kotlin/andreas311/miso/domain/user/adapter/input/UserAdapter.kt @@ -5,17 +5,25 @@ import andreas311.miso.domain.user.adapter.input.data.response.PointResponse import andreas311.miso.domain.user.adapter.input.data.response.UserInfoResponse import andreas311.miso.domain.user.adapter.input.mapper.UserDataMapper import andreas311.miso.domain.user.application.port.input.GetPointUseCase +import andreas311.miso.domain.user.application.port.input.GivePointUseCase import andreas311.miso.domain.user.application.port.input.UserInfoUseCase import org.springframework.http.HttpStatus import org.springframework.http.ResponseEntity import org.springframework.web.bind.annotation.GetMapping +import org.springframework.web.bind.annotation.PostMapping @RequestController("/user") class UserAdapter( private val userDataMapper: UserDataMapper, private val userInfoUseCase: UserInfoUseCase, private val getPointUseCase: GetPointUseCase, + private val givePointUseCase: GivePointUseCase ) { + @PostMapping("/give") + fun givePoint(): ResponseEntity = + givePointUseCase.execute() + .let { ResponseEntity.status(HttpStatus.OK).build() } + @GetMapping fun userInfo(): ResponseEntity = userInfoUseCase.execute() diff --git a/src/main/kotlin/andreas311/miso/domain/user/application/port/input/GivePointUseCase.kt b/src/main/kotlin/andreas311/miso/domain/user/application/port/input/GivePointUseCase.kt new file mode 100644 index 00000000..b4e1aafe --- /dev/null +++ b/src/main/kotlin/andreas311/miso/domain/user/application/port/input/GivePointUseCase.kt @@ -0,0 +1,5 @@ +package andreas311.miso.domain.user.application.port.input + +interface GivePointUseCase { + fun execute() +} \ No newline at end of file diff --git a/src/main/kotlin/andreas311/miso/domain/user/application/service/GivePointService.kt b/src/main/kotlin/andreas311/miso/domain/user/application/service/GivePointService.kt new file mode 100644 index 00000000..6d5ed38e --- /dev/null +++ b/src/main/kotlin/andreas311/miso/domain/user/application/service/GivePointService.kt @@ -0,0 +1,18 @@ +package andreas311.miso.domain.user.application.service + +import andreas311.miso.common.annotation.RollbackService +import andreas311.miso.domain.auth.application.port.output.UserSecurityPort +import andreas311.miso.domain.user.application.port.input.GivePointUseCase +import andreas311.miso.domain.user.application.port.output.CommandUserPort + +@RollbackService +class GivePointService( + private val commandUserPort: CommandUserPort, + private val userSecurityPort: UserSecurityPort +) : GivePointUseCase { + override fun execute() { + val user = userSecurityPort.currentUser() + + commandUserPort.saveUser(user.addPoint(100)) + } +} \ No newline at end of file