-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7e2893a
commit c22cd30
Showing
2 changed files
with
34 additions
and
0 deletions.
There are no files selected for viewing
9 changes: 9 additions & 0 deletions
9
src/main/java/slvtwn/khu/toyouserver/common/ToyouResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package slvtwn.khu.toyouserver.common; | ||
|
||
// TODO: 효율적인 예외처리 Wrapping 과정에 대해 고민 | ||
public record ToyouResponse<T>(String code, T data) { | ||
|
||
public static <T> ToyouResponse<T> success(T data) { | ||
return new ToyouResponse<>("SUCCESS", data); | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
src/main/java/slvtwn/khu/toyouserver/user/controller/UserController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<UserResponse> findUser(@PathVariable Long userId) { | ||
UserResponse userResponse = userService.findUser(userId); | ||
|
||
return ToyouResponse.success(userResponse); | ||
} | ||
} |