diff --git a/src/main/java/slvtwn/khu/toyouserver/application/UserService.java b/src/main/java/slvtwn/khu/toyouserver/application/UserService.java deleted file mode 100644 index 033942d..0000000 --- a/src/main/java/slvtwn/khu/toyouserver/application/UserService.java +++ /dev/null @@ -1,25 +0,0 @@ -package slvtwn.khu.toyouserver.application; - -import org.springframework.stereotype.Service; -import slvtwn.khu.toyouserver.common.ErrorType; -import slvtwn.khu.toyouserver.domain.User; -import slvtwn.khu.toyouserver.dto.UserResponse; -import slvtwn.khu.toyouserver.exception.ToyouException; -import slvtwn.khu.toyouserver.persistance.UserRepository; - -@Service -public class UserService { - - private final UserRepository userRepository; - - public UserService(UserRepository userRepository) { - this.userRepository = userRepository; - } - - public UserResponse findUser(Long userId) { - User user = userRepository.findById(userId) - .orElseThrow(() -> new ToyouException(ErrorType.USER_NOT_FOUND)); - return new UserResponse(user.getId(), user.getName(), user.getBirthday(), - user.getProfilePicture()); - } -} diff --git a/src/main/java/slvtwn/khu/toyouserver/dto/UserResponse.java b/src/main/java/slvtwn/khu/toyouserver/dto/UserResponse.java index de6b109..8bbb578 100644 --- a/src/main/java/slvtwn/khu/toyouserver/dto/UserResponse.java +++ b/src/main/java/slvtwn/khu/toyouserver/dto/UserResponse.java @@ -1,6 +1,11 @@ package slvtwn.khu.toyouserver.dto; import java.time.LocalDate; +import slvtwn.khu.toyouserver.domain.User; -public record UserResponse(Long id, String name, LocalDate birthday, String imageUrl) { +public record UserResponse(Long id, String name, LocalDate birthday, String introduction, String imageUrl) { + + public static UserResponse of(User user) { + return new UserResponse(user.getId(), user.getName(), user.getBirthday(), user.getIntroduction(), user.getProfilePicture()); + } } diff --git a/src/main/java/slvtwn/khu/toyouserver/presentation/UserController.java b/src/main/java/slvtwn/khu/toyouserver/presentation/UserController.java index 4ca6a16..00a848d 100644 --- a/src/main/java/slvtwn/khu/toyouserver/presentation/UserController.java +++ b/src/main/java/slvtwn/khu/toyouserver/presentation/UserController.java @@ -3,7 +3,6 @@ import lombok.RequiredArgsConstructor; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; -import slvtwn.khu.toyouserver.application.UserService; import slvtwn.khu.toyouserver.common.UserAuthentication; import slvtwn.khu.toyouserver.domain.User; import slvtwn.khu.toyouserver.dto.UserResponse; @@ -12,10 +11,8 @@ @RestController public class UserController { - private final UserService userService; - - @GetMapping("/users") - public UserResponse findUser(@UserAuthentication User user) { - return userService.findUser(user.getId()); - } + @GetMapping("/me") + public UserResponse getProfile(@UserAuthentication User user) { + return UserResponse.of(user); + } }