diff --git a/src/main/java/fairytale/tbd/domain/user/service/UserQueryService.java b/src/main/java/fairytale/tbd/domain/user/service/UserQueryService.java index 862b12a..72f64f7 100644 --- a/src/main/java/fairytale/tbd/domain/user/service/UserQueryService.java +++ b/src/main/java/fairytale/tbd/domain/user/service/UserQueryService.java @@ -3,6 +3,7 @@ import java.util.Optional; import fairytale.tbd.domain.user.entity.User; +import fairytale.tbd.domain.user.web.dto.UserResponseDTO; public interface UserQueryService { @@ -11,4 +12,6 @@ public interface UserQueryService { void updateRefreshToken(User user, String reIssuedRefreshToken); Optional getUserWithUserId(Long userId); + + UserResponseDTO.MyPageGetResultDto getUserMyPage(User user); } diff --git a/src/main/java/fairytale/tbd/domain/user/service/UserQueryServiceImpl.java b/src/main/java/fairytale/tbd/domain/user/service/UserQueryServiceImpl.java index 2882fc2..7f38004 100644 --- a/src/main/java/fairytale/tbd/domain/user/service/UserQueryServiceImpl.java +++ b/src/main/java/fairytale/tbd/domain/user/service/UserQueryServiceImpl.java @@ -7,6 +7,7 @@ import fairytale.tbd.domain.user.entity.User; import fairytale.tbd.domain.user.repository.UserRepository; +import fairytale.tbd.domain.user.web.dto.UserResponseDTO; import lombok.RequiredArgsConstructor; @Service @@ -41,4 +42,12 @@ public Optional getUserWithUserId(Long userId) { return userRepository.findById(userId); } + @Override + public UserResponseDTO.MyPageGetResultDto getUserMyPage(User user) { + return UserResponseDTO.MyPageGetResultDto.builder() + .userName(user.getUsername()) + .imageUrl(user.getFaceImageUrl()) + .uploadedVoice(user.getVoice() != null) + .build(); + } } diff --git a/src/main/java/fairytale/tbd/domain/user/web/controller/UserRestController.java b/src/main/java/fairytale/tbd/domain/user/web/controller/UserRestController.java index 9a185cf..01c24d9 100644 --- a/src/main/java/fairytale/tbd/domain/user/web/controller/UserRestController.java +++ b/src/main/java/fairytale/tbd/domain/user/web/controller/UserRestController.java @@ -2,6 +2,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; @@ -10,8 +11,10 @@ import fairytale.tbd.domain.user.converter.UserConverter; import fairytale.tbd.domain.user.entity.User; import fairytale.tbd.domain.user.service.UserCommandService; +import fairytale.tbd.domain.user.service.UserQueryService; import fairytale.tbd.domain.user.web.dto.UserRequestDTO; import fairytale.tbd.domain.user.web.dto.UserResponseDTO; +import fairytale.tbd.global.annotation.LoginUser; import fairytale.tbd.global.response.ApiResponse; import jakarta.validation.Valid; import lombok.RequiredArgsConstructor; @@ -22,6 +25,7 @@ public class UserRestController { private final UserCommandService userCommandService; + private final UserQueryService userQueryService; private static final Logger LOGGER = LogManager.getLogger(UserRestController.class); /** @@ -33,4 +37,14 @@ public ApiResponse join(@Valid @RequestBody Us User user = userCommandService.addUser(request); return ApiResponse.onSuccess(UserConverter.toAddUserResultDTO(user)); } + + /** + * 사용자 마이페이지 데이터 조회 + */ + + @GetMapping("") + public ApiResponse getMyPage(@LoginUser User user) { + UserResponseDTO.MyPageGetResultDto result = userQueryService.getUserMyPage(user); + return ApiResponse.onSuccess(result); + } } diff --git a/src/main/java/fairytale/tbd/domain/user/web/dto/UserResponseDTO.java b/src/main/java/fairytale/tbd/domain/user/web/dto/UserResponseDTO.java index e3e374d..3769f90 100644 --- a/src/main/java/fairytale/tbd/domain/user/web/dto/UserResponseDTO.java +++ b/src/main/java/fairytale/tbd/domain/user/web/dto/UserResponseDTO.java @@ -12,8 +12,19 @@ public class UserResponseDTO { @Getter @NoArgsConstructor @AllArgsConstructor - public static class AddUserResultDTO{ + public static class AddUserResultDTO { private Long userId; private LocalDateTime createdAt; } + + @Builder + @Getter + @NoArgsConstructor + @AllArgsConstructor + public static class MyPageGetResultDto { + private String imageUrl; + private String userName; + + private Boolean uploadedVoice; + } }