diff --git a/src/main/kotlin/com/yourssu/ssudateserver/controller/UserController.kt b/src/main/kotlin/com/yourssu/ssudateserver/controller/UserController.kt index cba5768..2045696 100644 --- a/src/main/kotlin/com/yourssu/ssudateserver/controller/UserController.kt +++ b/src/main/kotlin/com/yourssu/ssudateserver/controller/UserController.kt @@ -8,6 +8,7 @@ import com.yourssu.ssudateserver.dto.request.UpdateMaleRequestDto import com.yourssu.ssudateserver.dto.response.RefreshTokenResponseDto import com.yourssu.ssudateserver.dto.response.RegisterResponseDto import com.yourssu.ssudateserver.dto.response.UpdateResponseDto +import com.yourssu.ssudateserver.dto.response.UserInfoResponseDto import com.yourssu.ssudateserver.dto.security.UserPrincipal import com.yourssu.ssudateserver.enums.Animals import com.yourssu.ssudateserver.enums.FemaleAnimals @@ -16,6 +17,7 @@ import com.yourssu.ssudateserver.enums.MaleAnimals import com.yourssu.ssudateserver.exception.logic.AllCanNotRegisterException import com.yourssu.ssudateserver.service.UserService import org.springframework.security.core.annotation.AuthenticationPrincipal +import org.springframework.web.bind.annotation.GetMapping import org.springframework.web.bind.annotation.PatchMapping import org.springframework.web.bind.annotation.PostMapping import org.springframework.web.bind.annotation.RequestBody @@ -68,6 +70,11 @@ class UserController( ) } + @GetMapping("/users/my") + fun getMyInfo(@AuthenticationPrincipal userPrincipal: UserPrincipal): UserInfoResponseDto { + return userService.getMyInfo(oauthName = userPrincipal.name) + } + @PatchMapping("/users/my/male") fun updateMaleInfo( @RequestBody updateRequestDto: UpdateMaleRequestDto, diff --git a/src/main/kotlin/com/yourssu/ssudateserver/dto/response/UserInfoResponseDto.kt b/src/main/kotlin/com/yourssu/ssudateserver/dto/response/UserInfoResponseDto.kt new file mode 100644 index 0000000..9b6909b --- /dev/null +++ b/src/main/kotlin/com/yourssu/ssudateserver/dto/response/UserInfoResponseDto.kt @@ -0,0 +1,19 @@ +package com.yourssu.ssudateserver.dto.response + +import com.yourssu.ssudateserver.enums.Animals +import com.yourssu.ssudateserver.enums.Gender +import com.yourssu.ssudateserver.enums.MBTI +import java.time.LocalDateTime + +data class UserInfoResponseDto( + val id: Long, + var animals: Animals, + var mbti: MBTI, + var nickName: String, + var introduction: String, + var contact: String, + var weight: Int, + var ticket: Int, + val gender: Gender, + val createdAt: LocalDateTime, +) diff --git a/src/main/kotlin/com/yourssu/ssudateserver/service/UserService.kt b/src/main/kotlin/com/yourssu/ssudateserver/service/UserService.kt index 6f1e998..a1dbde5 100644 --- a/src/main/kotlin/com/yourssu/ssudateserver/service/UserService.kt +++ b/src/main/kotlin/com/yourssu/ssudateserver/service/UserService.kt @@ -3,6 +3,7 @@ package com.yourssu.ssudateserver.service import com.yourssu.ssudateserver.dto.response.RefreshTokenResponseDto import com.yourssu.ssudateserver.dto.response.RegisterResponseDto import com.yourssu.ssudateserver.dto.response.UpdateResponseDto +import com.yourssu.ssudateserver.dto.response.UserInfoResponseDto import com.yourssu.ssudateserver.entity.User import com.yourssu.ssudateserver.enums.Animals import com.yourssu.ssudateserver.enums.Gender @@ -30,6 +31,24 @@ class UserService( return userRepository.findByOauthName(oauthName) } + fun getMyInfo(oauthName: String): UserInfoResponseDto { + val user = + userRepository.findByOauthName(oauthName) ?: throw UserNotFoundException("해당 oauthName인 유저가 없습니다.") + + return UserInfoResponseDto( + id = user.id!!, + animals = user.animals, + mbti = user.mbti, + nickName = user.nickName, + introduction = user.introduction, + contact = user.contact, + weight = user.weight, + ticket = user.ticket, + gender = user.gender, + createdAt = user.createdAt, + ) + } + fun refreshToken(refreshToken: String, oauthName: String): RefreshTokenResponseDto { val foundedToken = refreshTokenService.findRefreshToken(oauthName) ?: throw RefreshTokenNotFoundException("유저의 refreshToken이 존재하지 않습니다.")