Skip to content

Commit

Permalink
Merge pull request #60 from TeamMiso/feat/point-give
Browse files Browse the repository at this point in the history
 포인트 지급하기 API 구현
  • Loading branch information
uuuuuuuk authored Mar 25, 2024
2 parents 9ed1623 + f735eee commit 4bd80b0
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
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))
}
}

0 comments on commit 4bd80b0

Please sign in to comment.