Skip to content

Commit

Permalink
GetUserInfo API 추가 (#223)
Browse files Browse the repository at this point in the history
* GetUserInfo API spec 추가

* GetUserInfo API 구현 추가
  • Loading branch information
Zeniuus authored Oct 29, 2023
1 parent 087857d commit 4725ee7
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 1 deletion.
23 changes: 23 additions & 0 deletions app-server/subprojects/api/scc-api/api-spec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,16 @@ paths:
schema:
$ref: '#/components/schemas/GetChallengeResponseDto'

/getUserInfo:
get:
summary: 유저 정보를 조회한다.
responses:
'200':
content:
application/json:
schema:
$ref: '#/components/schemas/GetUserInfoResponseDto'

/giveBuildingAccessibilityUpvote:
post:
summary: "'이 정보가 도움이 돼요'를 준다."
Expand Down Expand Up @@ -1173,6 +1183,19 @@ components:
required:
- invitationCode

GetUserInfoRequestDto:
type: object
properties: {}
required: []

GetUserInfoResponseDto:
type: object
properties:
user:
$ref: '#/components/schemas/User'
required:
- user

GiveBuildingAccessibilityUpvoteRequestDto:
type: object
properties:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package club.staircrusher.user.application.port.`in`.use_case

import club.staircrusher.stdlib.di.annotation.Component
import club.staircrusher.stdlib.persistence.TransactionManager
import club.staircrusher.user.application.port.out.persistence.UserRepository
import club.staircrusher.user.domain.model.User

@Component
class GetUserUseCase(
private val transactionManager: TransactionManager,
private val userRepository: UserRepository,
) {
fun handle(userId: String): User = transactionManager.doInTransaction {
return@doInTransaction userRepository.findById(userId)
}
}
Original file line number Diff line number Diff line change
@@ -1,24 +1,38 @@
package club.staircrusher.user.infra.adapter.`in`.controller

import club.staircrusher.api.spec.dto.GetUserInfoResponseDto
import club.staircrusher.api.spec.dto.UpdateUserInfoPost200Response
import club.staircrusher.api.spec.dto.UpdateUserInfoPostRequest
import club.staircrusher.spring_web.security.app.SccAppAuthentication
import club.staircrusher.user.application.port.`in`.UserApplicationService
import club.staircrusher.user.application.port.`in`.use_case.GetUserUseCase
import club.staircrusher.user.infra.adapter.`in`.converter.toDTO
import club.staircrusher.user.infra.adapter.`in`.converter.toModel
import org.springframework.http.ResponseEntity
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.PostMapping
import org.springframework.web.bind.annotation.RequestBody
import org.springframework.web.bind.annotation.RestController

@RestController
class UserController(
private val userApplicationService: UserApplicationService,
private val getUserUseCase: GetUserUseCase,
) {
@GetMapping("/getUserInfo")
fun getUserInfo(
authentication: SccAppAuthentication,
): GetUserInfoResponseDto {
val user = getUserUseCase.handle(authentication.principal)
return GetUserInfoResponseDto(
user = user.toDTO(),
)
}

@PostMapping("/updateUserInfo")
fun updateUserInfo(
@RequestBody request: UpdateUserInfoPostRequest,
authentication: SccAppAuthentication
authentication: SccAppAuthentication,
): UpdateUserInfoPost200Response {
val updatedUser = userApplicationService.updateUserInfo(
userId = authentication.principal,
Expand Down

0 comments on commit 4725ee7

Please sign in to comment.