diff --git a/src/main/java/slvtwn/khu/toyouserver/common/ToyouResponse.java b/src/main/java/slvtwn/khu/toyouserver/common/ToyouResponse.java new file mode 100644 index 0000000..2a12f77 --- /dev/null +++ b/src/main/java/slvtwn/khu/toyouserver/common/ToyouResponse.java @@ -0,0 +1,9 @@ +package slvtwn.khu.toyouserver.common; + +// TODO: 효율적인 예외처리 Wrapping 과정에 대해 고민 +public record ToyouResponse(String code, T data) { + + public static ToyouResponse success(T data) { + return new ToyouResponse<>("SUCCESS", data); + } +} diff --git a/src/main/java/slvtwn/khu/toyouserver/user/controller/UserController.java b/src/main/java/slvtwn/khu/toyouserver/user/controller/UserController.java new file mode 100644 index 0000000..dde04db --- /dev/null +++ b/src/main/java/slvtwn/khu/toyouserver/user/controller/UserController.java @@ -0,0 +1,25 @@ +package slvtwn.khu.toyouserver.user.controller; + +import lombok.RequiredArgsConstructor; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RestController; +import slvtwn.khu.toyouserver.common.ToyouResponse; +import slvtwn.khu.toyouserver.user.dto.UserResponse; +import slvtwn.khu.toyouserver.user.service.UserService; + +@RequiredArgsConstructor +@RestController +public class UserController { + + private final UserService userService; + + @GetMapping("/users/{userId}") + public ToyouResponse findUser(@PathVariable Long userId) { + UserResponse userResponse = userService.findUser(userId); + + return ToyouResponse.success(userResponse); + } +}