Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🔀 :: 포인트 지급하기 API 구현 #60

Merged
merged 3 commits into from
Mar 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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<Void> =
givePointUseCase.execute()
.let { ResponseEntity.status(HttpStatus.OK).build() }

@GetMapping
fun userInfo(): ResponseEntity<UserInfoResponse> =
userInfoUseCase.execute()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package andreas311.miso.domain.user.application.port.input

interface GivePointUseCase {
fun execute()
}
Original file line number Diff line number Diff line change
@@ -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))
}
}
Loading