Skip to content

Commit

Permalink
Merge pull request #58 from TeamMiso/feat/point-info
Browse files Browse the repository at this point in the history
포인트 정보 불러오기 API 구현
  • Loading branch information
uuuuuuuk authored Mar 25, 2024
2 parents 59ab15b + c67188f commit 9ed1623
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package andreas311.miso.domain.user.adapter.input

import andreas311.miso.common.annotation.RequestController
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.UserInfoUseCase
import org.springframework.http.HttpStatus
import org.springframework.http.ResponseEntity
Expand All @@ -11,11 +13,18 @@ import org.springframework.web.bind.annotation.GetMapping
@RequestController("/user")
class UserAdapter(
private val userDataMapper: UserDataMapper,
private val userInfoUseCase: UserInfoUseCase
private val userInfoUseCase: UserInfoUseCase,
private val getPointUseCase: GetPointUseCase,
) {
@GetMapping
fun userInfo(): ResponseEntity<UserInfoResponse> =
userInfoUseCase.execute()
.let { userDataMapper.toResponse(it) }
.let { ResponseEntity.status(HttpStatus.OK).body(it) }

@GetMapping("/point")
fun getPoint(): ResponseEntity<PointResponse> =
getPointUseCase.execute()
.let { userDataMapper.toResponse(it) }
.let { ResponseEntity.status(HttpStatus.OK).body(it) }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package andreas311.miso.domain.user.adapter.input.data.response

data class PointResponse(
val point: Int
)
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package andreas311.miso.domain.user.adapter.input.mapper

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.application.port.input.dto.PointDto
import andreas311.miso.domain.user.application.port.input.dto.UserInfoDto
import org.springframework.stereotype.Component

Expand All @@ -12,4 +14,9 @@ class UserDataMapper {
email = userInfoDto.email,
role = userInfoDto.role
)

fun toResponse(pointDto: PointDto): PointResponse =
PointResponse(
point = pointDto.point
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package andreas311.miso.domain.user.application.port.input

import andreas311.miso.domain.user.application.port.input.dto.PointDto

interface GetPointUseCase {
fun execute(): PointDto
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package andreas311.miso.domain.user.application.port.input.dto

import andreas311.miso.domain.user.domain.User

data class PointDto(
val point: Int
) {
constructor(user: User) : this(
point = user.point
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package andreas311.miso.domain.user.application.service

import andreas311.miso.common.annotation.ReadOnlyRollbackService
import andreas311.miso.domain.auth.application.port.output.UserSecurityPort
import andreas311.miso.domain.user.application.port.input.GetPointUseCase
import andreas311.miso.domain.user.application.port.input.dto.PointDto

@ReadOnlyRollbackService
class GetPointService(
private val userSecurityPort: UserSecurityPort
) : GetPointUseCase {
override fun execute(): PointDto {
val user = userSecurityPort.currentUser()

return PointDto(user)
}
}

0 comments on commit 9ed1623

Please sign in to comment.