diff --git a/src/main/java/org/alongtheblue/alongtheblue_server/domain/userInfo/api/UserInfoController.java b/src/main/java/org/alongtheblue/alongtheblue_server/domain/userInfo/api/UserInfoController.java index 4aba4d8..a9a55f6 100644 --- a/src/main/java/org/alongtheblue/alongtheblue_server/domain/userInfo/api/UserInfoController.java +++ b/src/main/java/org/alongtheblue/alongtheblue_server/domain/userInfo/api/UserInfoController.java @@ -7,6 +7,7 @@ import org.alongtheblue.alongtheblue_server.domain.userInfo.application.UserInfoService; import org.alongtheblue.alongtheblue_server.domain.userInfo.domain.UserInfo; import org.alongtheblue.alongtheblue_server.domain.userInfo.dto.CreateUserInfoDto; +import org.alongtheblue.alongtheblue_server.domain.userInfo.dto.UserInfoDto; import org.alongtheblue.alongtheblue_server.global.common.response.ApiResponse; import org.springframework.web.bind.annotation.*; @@ -33,8 +34,9 @@ public ApiResponse> retrieveAllUserInfo() { @Operation(summary = "ID로 UserInfo 조회 API") @GetMapping("/user") - public ApiResponse retrieveUserInfo(@RequestHeader("Authorization") String uid) { - return userInfoService.retrieveUserInfo(uid); + public ApiResponse retrieveUserInfo(@RequestHeader("Authorization") String uid) { + return userInfoService.retrieveUserInfoDto(uid); +// return userInfoService.retrieveUserInfo(uid); } } diff --git a/src/main/java/org/alongtheblue/alongtheblue_server/domain/userInfo/application/UserInfoService.java b/src/main/java/org/alongtheblue/alongtheblue_server/domain/userInfo/application/UserInfoService.java index 682ac58..c6d344d 100644 --- a/src/main/java/org/alongtheblue/alongtheblue_server/domain/userInfo/application/UserInfoService.java +++ b/src/main/java/org/alongtheblue/alongtheblue_server/domain/userInfo/application/UserInfoService.java @@ -5,6 +5,7 @@ import org.alongtheblue.alongtheblue_server.domain.userInfo.dao.UserInfoRepository; import org.alongtheblue.alongtheblue_server.domain.userInfo.domain.UserInfo; import org.alongtheblue.alongtheblue_server.domain.userInfo.dto.CreateUserInfoServiceDto; +import org.alongtheblue.alongtheblue_server.domain.userInfo.dto.UserInfoDto; import org.alongtheblue.alongtheblue_server.global.common.response.ApiResponse; import org.alongtheblue.alongtheblue_server.global.error.ErrorCode; import org.springframework.stereotype.Service; @@ -74,4 +75,13 @@ public ApiResponse retrieveUserInfo(String uid) { return ApiResponse.ok("사용자 정보를 성공적으로 조회했습니다.", userInfo); } + public ApiResponse retrieveUserInfoDto(String uid) { + UserInfo userInfo = retrieveUserInfo(uid).getData(); + UserInfoDto userInfoDto = new UserInfoDto( + userInfo.getUid(), + userInfo.getUserName(), + userInfo.getProfileImageUrl() + ); + return ApiResponse.ok("사용자 정보를 성공적으로 조회했습니다.", userInfoDto); + } } diff --git a/src/main/java/org/alongtheblue/alongtheblue_server/domain/userInfo/dto/UserInfoDto.java b/src/main/java/org/alongtheblue/alongtheblue_server/domain/userInfo/dto/UserInfoDto.java new file mode 100644 index 0000000..1d439dc --- /dev/null +++ b/src/main/java/org/alongtheblue/alongtheblue_server/domain/userInfo/dto/UserInfoDto.java @@ -0,0 +1,9 @@ +package org.alongtheblue.alongtheblue_server.domain.userInfo.dto; + +public record UserInfoDto( + String uid, + String userName, +// String userComment, + String profileImg +) { +} diff --git a/src/main/java/org/alongtheblue/alongtheblue_server/global/data/tourcommunity/TourCommunityController.java b/src/main/java/org/alongtheblue/alongtheblue_server/global/data/tourcommunity/TourCommunityController.java index 38d611c..9063760 100644 --- a/src/main/java/org/alongtheblue/alongtheblue_server/global/data/tourcommunity/TourCommunityController.java +++ b/src/main/java/org/alongtheblue/alongtheblue_server/global/data/tourcommunity/TourCommunityController.java @@ -46,7 +46,7 @@ public UserTourCourse createTourCourse( @Operation(summary = "여행따라 전체 게시물 조회 API") @GetMapping("/list") - public List getAllUserTourCourses(){ + public ApiResponse> getAllUserTourCourses(){ return tourCommunityService.getAllUserTourCourses(); } diff --git a/src/main/java/org/alongtheblue/alongtheblue_server/global/data/tourcommunity/TourCommunityService.java b/src/main/java/org/alongtheblue/alongtheblue_server/global/data/tourcommunity/TourCommunityService.java index 6244cb5..0e09c2a 100644 --- a/src/main/java/org/alongtheblue/alongtheblue_server/global/data/tourcommunity/TourCommunityService.java +++ b/src/main/java/org/alongtheblue/alongtheblue_server/global/data/tourcommunity/TourCommunityService.java @@ -3,6 +3,7 @@ import lombok.RequiredArgsConstructor; import org.alongtheblue.alongtheblue_server.domain.userInfo.application.UserInfoService; import org.alongtheblue.alongtheblue_server.domain.userInfo.domain.UserInfo; +import org.alongtheblue.alongtheblue_server.domain.userInfo.dto.UserInfoDto; import org.alongtheblue.alongtheblue_server.global.adapter.S3Adapter; import org.alongtheblue.alongtheblue_server.global.common.response.ApiResponse; import org.alongtheblue.alongtheblue_server.global.data.tourcommunity.dto.request.CreateUserTourCourseServiceRequestDto; @@ -120,22 +121,31 @@ private String saveImageToS3(MultipartFile image) { } // 여행따라 전체 조회 - 페이지네이션 필요 - public List getAllUserTourCourses() { + public ApiResponse> getAllUserTourCourses() { List userCourses = userTourCourseRepository.findAll(); List userCourseDtoList = new ArrayList<>(); for (UserTourCourse userCourse : userCourses) { + UserInfo userInfo = userCourse.getUserInfo(); + UserInfoDto userInfoDto = new UserInfoDto( + userInfo.getUid(), + userInfo.getUserName(), + userInfo.getProfileImageUrl() + ); UserTourCourseDTO userCourseDto = new UserTourCourseDTO(); + userCourseDto.setUser(userInfoDto); userCourseDto.setTitle(userCourse.getTitle()); - userCourseDto.setWriting(userCourse.getWriting()); + userCourseDto.setContent(userCourse.getWriting()); + userCourseDto.setId(userCourse.getId()); // dto.setTags(tourPostHashTagRepository.findBytourCourseForHashTag(tour)); - List items = tourPostItemRepository.findByuserTourCourse(userCourse); + List items = tourPostItemRepository.findByUserTourCourse(userCourse); List images = tourImageRepository.findBytourPostItem(items.get(0)); - if (!images.isEmpty()) userCourseDto.setImgUrl(images.get(0).getUrl()); + if (!images.isEmpty()) + userCourseDto.setImgUrl(images.get(0).getUrl()); // userCourseDto.setImgUrl(tourImageRepository.findBytourPostItem(items.get(0)).get(0).getUrl()); userCourseDtoList.add(userCourseDto); } - return userCourseDtoList; + return ApiResponse.ok(userCourseDtoList); } public UserTourCourse findById(Long id) { diff --git a/src/main/java/org/alongtheblue/alongtheblue_server/global/data/tourcommunity/TourPostItemRepository.java b/src/main/java/org/alongtheblue/alongtheblue_server/global/data/tourcommunity/TourPostItemRepository.java index a3fd410..0f23b38 100644 --- a/src/main/java/org/alongtheblue/alongtheblue_server/global/data/tourcommunity/TourPostItemRepository.java +++ b/src/main/java/org/alongtheblue/alongtheblue_server/global/data/tourcommunity/TourPostItemRepository.java @@ -5,5 +5,5 @@ import java.util.List; public interface TourPostItemRepository extends JpaRepository { - List findByuserTourCourse (UserTourCourse userTourCourse); + List findByUserTourCourse(UserTourCourse userCourse); } diff --git a/src/main/java/org/alongtheblue/alongtheblue_server/global/data/tourcommunity/UserTourCourseDTO.java b/src/main/java/org/alongtheblue/alongtheblue_server/global/data/tourcommunity/UserTourCourseDTO.java index c63ac8d..afef686 100644 --- a/src/main/java/org/alongtheblue/alongtheblue_server/global/data/tourcommunity/UserTourCourseDTO.java +++ b/src/main/java/org/alongtheblue/alongtheblue_server/global/data/tourcommunity/UserTourCourseDTO.java @@ -2,14 +2,18 @@ import lombok.Getter; import lombok.Setter; +import org.alongtheblue.alongtheblue_server.domain.userInfo.dto.UserInfoDto; +import org.alongtheblue.alongtheblue_server.global.data.course.Course; import java.util.List; @Getter @Setter public class UserTourCourseDTO { + private UserInfoDto user; + private Long id; private String title; - private String writing; + private String content; // private List tags; private String imgUrl; - private List postItems; +// private List postItems; }