Skip to content

Commit 4f299f0

Browse files
committed
feat: 유저조회하기
1 parent fe619df commit 4f299f0

3 files changed

Lines changed: 17 additions & 0 deletions

File tree

‎src/main/kotlin/com/ansimtouchserver/domain/user/controller/UserController.kt‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import com.ansimtouchserver.global.exception.CustomException
1212
import io.swagger.v3.oas.annotations.Operation
1313
import io.swagger.v3.oas.annotations.tags.Tag
1414
import org.springframework.web.bind.annotation.GetMapping
15+
import org.springframework.web.bind.annotation.PathVariable
1516
import org.springframework.web.bind.annotation.PostMapping
1617
import org.springframework.web.bind.annotation.RequestBody
1718
import org.springframework.web.bind.annotation.RequestMapping
@@ -32,6 +33,12 @@ class UserController(
3233
return userService.getMe(principal)
3334
}
3435

36+
@Operation(summary = "마이페이지")
37+
@GetMapping("/{userId}")
38+
fun getUser(@PathVariable userId: Long): GetMeResponse {
39+
return userService.getUser(userId)
40+
}
41+
3542
@Operation(summary = "fcm 토큰 입력")
3643
@PostMapping("/fcm")
3744
fun registerFcmToken(principal: Principal, @RequestBody fcmRequest: FcmRequest): BaseResponse<Unit> {

‎src/main/kotlin/com/ansimtouchserver/domain/user/dto/response/GetMeResponse.kt‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.ansimtouchserver.domain.user.dto.response
22

33
import com.ansimtouchserver.domain.user.entity.UserType
4+
import java.time.LocalDateTime
45

56
data class GetMeResponse (
67
val id: Long = 0,
@@ -12,4 +13,8 @@ data class GetMeResponse (
1213
val userType: UserType? = null,
1314

1415
val fcmToken: String? = null,
16+
17+
var lastLocationLa: Double? = null,
18+
var lastLocationLo: Double? = null,
19+
var lastUpdatedAt: LocalDateTime? = null,
1520
)

‎src/main/kotlin/com/ansimtouchserver/domain/user/service/UserService.kt‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ class UserService (
3131
return formUser(user)
3232
}
3333

34+
fun getUser(userId: Long): GetMeResponse {
35+
val user = userRepository.findById(userId).orElseThrow{CustomException(UserErrorCode.USER_NOT_FOUND)}
36+
return formUser(user)
37+
}
38+
3439
fun registerFcmToken(principal: Principal, fcmToken: String): BaseResponse<Unit>{
3540
val user = userRepository.findByTel(principal.name).orElseThrow{CustomException(UserErrorCode.USER_NOT_FOUND)}
3641
user.fcmToken = fcmToken

0 commit comments

Comments
 (0)