From e19fb935f361299f3136c7be32d91824a4965db0 Mon Sep 17 00:00:00 2001 From: Jeongho Date: Thu, 16 May 2024 19:43:17 +0900 Subject: [PATCH 1/4] =?UTF-8?q?Fix:=20User=20=EA=B8=B0=EB=B3=B8=20?= =?UTF-8?q?=EC=A0=95=EB=B3=B4=20=EC=A1=B0=ED=9A=8C,=20=EC=88=98=EC=A0=95?= =?UTF-8?q?=20api=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../user/controller/UserController.java | 19 +++++++++---------- .../domain/user/service/UserService.java | 10 +++++++--- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/meetup/teame/backend/domain/user/controller/UserController.java b/src/main/java/com/meetup/teame/backend/domain/user/controller/UserController.java index 8cf75ec..c72727e 100644 --- a/src/main/java/com/meetup/teame/backend/domain/user/controller/UserController.java +++ b/src/main/java/com/meetup/teame/backend/domain/user/controller/UserController.java @@ -60,9 +60,9 @@ public ResponseEntity setUserPersonality(@RequestBody @Valid OnboardingReq 추후 로그인 적용 시에는 jwt토큰도 같이 전달해서 요청해주셔야 합니다. """) //기본 정보 조회 - @GetMapping("/{userId}/info") - public ResponseEntity getUserInfo(@PathVariable long userId) { - UserInfoRes userInfo = userService.getUserInfo(userId); + @GetMapping("/info") + public ResponseEntity getUserInfo() { + UserInfoRes userInfo = userService.getUserInfo(); return ResponseEntity.ok().body(userInfo); } @@ -72,9 +72,9 @@ public ResponseEntity getUserInfo(@PathVariable long userId) { 추후 로그인 적용 시에는 jwt토큰도 같이 전달해서 요청해주셔야 합니다. """) //기본 정보 수정 - @PutMapping("/{userId}/info") - public ResponseEntity updateUserInfo(@PathVariable long userId, @RequestBody UpdateUserReq request) { - UserInfoRes userInfo = userService.updateUserInfo(userId, request); + @PutMapping("/info") + public ResponseEntity updateUserInfo(@RequestBody UpdateUserReq request) { + UserInfoRes userInfo = userService.updateUserInfo(request); return ResponseEntity.ok().body(userInfo); } @@ -84,10 +84,9 @@ public ResponseEntity updateUserInfo(@PathVariable long userId, @Re """) //내 후기 목록 조회 - @GetMapping("/{userId}/review") - public ResponseEntity> getMyReviews(@PathVariable long userId, - @RequestParam String type) { - List myReviews = userService.getMyReviews(userId, type); + @GetMapping("/review") + public ResponseEntity> getMyReviews(@RequestParam String type) { + List myReviews = userService.getMyReviews(type); return ResponseEntity.ok().body(myReviews); } } diff --git a/src/main/java/com/meetup/teame/backend/domain/user/service/UserService.java b/src/main/java/com/meetup/teame/backend/domain/user/service/UserService.java index 9a3bc5c..2a72170 100644 --- a/src/main/java/com/meetup/teame/backend/domain/user/service/UserService.java +++ b/src/main/java/com/meetup/teame/backend/domain/user/service/UserService.java @@ -1,6 +1,7 @@ package com.meetup.teame.backend.domain.user.service; import com.meetup.teame.backend.domain.activity.repository.ActivityRepository; +import com.meetup.teame.backend.domain.auth.jwt.SecurityContextProvider; import com.meetup.teame.backend.domain.auth.oauth.dto.CreateUserRequest; import com.meetup.teame.backend.domain.experience.repository.ExperienceRepository; import com.meetup.teame.backend.domain.personality.Personality; @@ -62,7 +63,8 @@ public User createUser(CreateUserRequest request) { } //user info dto화 - public UserInfoRes getUserInfo(Long userId) { + public UserInfoRes getUserInfo() { + Long userId = SecurityContextProvider.getAuthenticatedUserId(); User user = findById(userId); return UserInfoRes.of(user); } @@ -79,14 +81,16 @@ public Long save(User user) { } @Transactional - public UserInfoRes updateUserInfo(Long userId, UpdateUserReq request) { + public UserInfoRes updateUserInfo(UpdateUserReq request) { + Long userId = SecurityContextProvider.getAuthenticatedUserId(); User updatedUser = findById(userId); updatedUser.update(request); return UserInfoRes.of(updatedUser); } //내 후기 조회 - public List getMyReviews(Long userId, String type) { + public List getMyReviews(String type) { + Long userId = SecurityContextProvider.getAuthenticatedUserId(); List myReviews = reviewRepository.findReviewsByUserId(userId, type); List reviews = myReviews.stream() .map(ReviewRes::of) From aefe1c54dba029f06fa4c2109e3d18f2ed430822 Mon Sep 17 00:00:00 2001 From: Jeongho Date: Thu, 16 May 2024 22:47:37 +0900 Subject: [PATCH 2/4] =?UTF-8?q?Feat:=20=EB=82=B4=20=ED=99=9C=EB=8F=99=20?= =?UTF-8?q?=EB=AA=A9=EB=A1=9D=20=EC=A1=B0=ED=9A=8C=ED=95=98=EA=B8=B0=20api?= =?UTF-8?q?=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/response/ActivityPageRes.java | 11 -------- .../domain/review/service/ReviewService.java | 1 + .../user/controller/UserController.java | 10 ++++++- .../domain/user/dto/response/UserInfoRes.java | 2 -- .../backend/domain/user/entity/User.java | 1 - .../domain/user/service/UserService.java | 27 +++++++++++++++++++ 6 files changed, 37 insertions(+), 15 deletions(-) delete mode 100644 src/main/java/com/meetup/teame/backend/domain/activity/dto/response/ActivityPageRes.java diff --git a/src/main/java/com/meetup/teame/backend/domain/activity/dto/response/ActivityPageRes.java b/src/main/java/com/meetup/teame/backend/domain/activity/dto/response/ActivityPageRes.java deleted file mode 100644 index acc533b..0000000 --- a/src/main/java/com/meetup/teame/backend/domain/activity/dto/response/ActivityPageRes.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.meetup.teame.backend.domain.activity.dto.response; - -import java.util.List; - -public record ActivityPageRes( - List activities, - int totalPages, - long totalElements) -{ - -} diff --git a/src/main/java/com/meetup/teame/backend/domain/review/service/ReviewService.java b/src/main/java/com/meetup/teame/backend/domain/review/service/ReviewService.java index ec0f873..8dd4e16 100644 --- a/src/main/java/com/meetup/teame/backend/domain/review/service/ReviewService.java +++ b/src/main/java/com/meetup/teame/backend/domain/review/service/ReviewService.java @@ -23,6 +23,7 @@ public class ReviewService { private final ExperienceRepository experienceRepository; private final DirectChatRoomRepository directChatRoomRepository; + @Transactional //후기 작성하기 public ReviewRes createReview(CreateReviewReq createReviewReq) { Experience mentor = experienceRepository.findById(createReviewReq.getMentorId()) diff --git a/src/main/java/com/meetup/teame/backend/domain/user/controller/UserController.java b/src/main/java/com/meetup/teame/backend/domain/user/controller/UserController.java index c72727e..c7f4bbf 100644 --- a/src/main/java/com/meetup/teame/backend/domain/user/controller/UserController.java +++ b/src/main/java/com/meetup/teame/backend/domain/user/controller/UserController.java @@ -1,5 +1,6 @@ package com.meetup.teame.backend.domain.user.controller; +import com.meetup.teame.backend.domain.activity.dto.response.ActivitySummaryRes; import com.meetup.teame.backend.domain.review.dto.response.ReviewRes; import com.meetup.teame.backend.domain.user.dto.request.OnboardingReq; import com.meetup.teame.backend.domain.user.dto.request.UpdateUserReq; @@ -84,9 +85,16 @@ public ResponseEntity updateUserInfo(@RequestBody UpdateUserReq req """) //내 후기 목록 조회 - @GetMapping("/review") + @GetMapping("/reviews") public ResponseEntity> getMyReviews(@RequestParam String type) { List myReviews = userService.getMyReviews(type); return ResponseEntity.ok().body(myReviews); } + + //내 활동 목록 조회(활동은 Activity가 아니라 GroupChatRoom) + @GetMapping("/activities") + public ResponseEntity> getMyActivities() { + List myActivities = userService.getMyActivities(); + return ResponseEntity.ok().body(myActivities); + } } diff --git a/src/main/java/com/meetup/teame/backend/domain/user/dto/response/UserInfoRes.java b/src/main/java/com/meetup/teame/backend/domain/user/dto/response/UserInfoRes.java index bdd6081..b21731b 100644 --- a/src/main/java/com/meetup/teame/backend/domain/user/dto/response/UserInfoRes.java +++ b/src/main/java/com/meetup/teame/backend/domain/user/dto/response/UserInfoRes.java @@ -16,8 +16,6 @@ public class UserInfoRes { private String email; - private String password; - private String imageUrl; private String location; diff --git a/src/main/java/com/meetup/teame/backend/domain/user/entity/User.java b/src/main/java/com/meetup/teame/backend/domain/user/entity/User.java index 5e9f8ae..6bcc759 100644 --- a/src/main/java/com/meetup/teame/backend/domain/user/entity/User.java +++ b/src/main/java/com/meetup/teame/backend/domain/user/entity/User.java @@ -73,7 +73,6 @@ public void setPersonalities(List personalities) { public void update(UpdateUserReq request) { this.name = request.getName(); this.email = request.getEmail(); - this.password = request.getPassword(); this.imageUrl = request.getImageUrl(); this.location = request.getLocation(); } diff --git a/src/main/java/com/meetup/teame/backend/domain/user/service/UserService.java b/src/main/java/com/meetup/teame/backend/domain/user/service/UserService.java index 2a72170..e61aa85 100644 --- a/src/main/java/com/meetup/teame/backend/domain/user/service/UserService.java +++ b/src/main/java/com/meetup/teame/backend/domain/user/service/UserService.java @@ -1,9 +1,16 @@ package com.meetup.teame.backend.domain.user.service; +import com.meetup.teame.backend.domain.activity.dto.response.ActivitySummaryRes; +import com.meetup.teame.backend.domain.activity.entity.Activity; import com.meetup.teame.backend.domain.activity.repository.ActivityRepository; import com.meetup.teame.backend.domain.auth.jwt.SecurityContextProvider; import com.meetup.teame.backend.domain.auth.oauth.dto.CreateUserRequest; +import com.meetup.teame.backend.domain.chatroom.entity.ChatRoom; +import com.meetup.teame.backend.domain.chatroom.entity.GroupChatRoom; +import com.meetup.teame.backend.domain.chatroom.entity.UserChatRoom; +import com.meetup.teame.backend.domain.chatroom.repository.GroupChatRoomRepository; import com.meetup.teame.backend.domain.experience.repository.ExperienceRepository; +import com.meetup.teame.backend.domain.like.repository.ActivityLikeRepository; import com.meetup.teame.backend.domain.personality.Personality; import com.meetup.teame.backend.domain.review.dto.response.ReviewRes; import com.meetup.teame.backend.domain.review.entity.Review; @@ -22,6 +29,7 @@ import org.springframework.transaction.annotation.Transactional; import java.time.LocalDate; +import java.util.ArrayList; import java.util.List; import java.util.Objects; import java.util.stream.Collectors; @@ -35,6 +43,8 @@ public class UserService { private final ActivityRepository activityRepository; private final ExperienceRepository experienceRepository; private final ReviewRepository reviewRepository; + private final GroupChatRoomRepository groupChatRoomRepository; + private final ActivityLikeRepository activityLikeRepository; public ReadMainRes readMainPage() { //todo 현재는 더미 유저지만 추후에는 SecurityContextHolder 정보를 조회해서 유저 정보를 가져와야 함 @@ -98,6 +108,23 @@ public List getMyReviews(String type) { return reviews; } + //내 활동 조회 + public List getMyActivities() { + Long userId = SecurityContextProvider.getAuthenticatedUserId(); + User user = findById(userId); + + List groupChatRooms = groupChatRoomRepository.findForUser(user); + List myActivities = groupChatRooms.stream() + .map(GroupChatRoom::getActivity) + .map(activity -> { + boolean isLiked = activityLikeRepository.existsByUserIdAndActivityId(userId, activity.getId()); + return ActivitySummaryRes.of(activity, isLiked); + }) + .collect(Collectors.toList()); + + return myActivities; + } + @Transactional public void setUserPersonality(OnboardingReq onboardingReq) { //todo 현재는 더미 유저지만 추후에는 SecurityContextHolder 정보를 조회해서 유저 정보를 가져와야 함 From ac29bcaad7900de64aa7ed68306701548048cdee Mon Sep 17 00:00:00 2001 From: Jeongho Date: Fri, 17 May 2024 00:25:27 +0900 Subject: [PATCH 3/4] =?UTF-8?q?Docs:=20swagger=20=EB=82=B4=20=ED=9B=84?= =?UTF-8?q?=EA=B8=B0=20=EB=AA=A9=EB=A1=9D=20=EC=A1=B0=ED=9A=8C=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../activity/dto/response/ActivityDetailsRes.java | 8 ++++++-- .../activity/dto/response/ActivitySummaryRes.java | 15 ++++++++------- .../dto/response/ReadMainActivityRes.java | 2 -- .../repository/custom/ReviewRepositoryImpl.java | 4 +++- .../domain/user/controller/UserController.java | 10 ++++++++-- .../domain/user/dto/request/UpdateUserReq.java | 2 -- 6 files changed, 25 insertions(+), 16 deletions(-) diff --git a/src/main/java/com/meetup/teame/backend/domain/activity/dto/response/ActivityDetailsRes.java b/src/main/java/com/meetup/teame/backend/domain/activity/dto/response/ActivityDetailsRes.java index 5fad62e..5952174 100644 --- a/src/main/java/com/meetup/teame/backend/domain/activity/dto/response/ActivityDetailsRes.java +++ b/src/main/java/com/meetup/teame/backend/domain/activity/dto/response/ActivityDetailsRes.java @@ -9,7 +9,9 @@ import org.hibernate.annotations.Comment; import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; import java.util.List; +import java.util.Locale; @NoArgsConstructor @AllArgsConstructor @@ -27,7 +29,7 @@ public class ActivityDetailsRes { private String location; - private LocalDateTime time; + private String time; private Long currentParticipants; @@ -38,13 +40,15 @@ public class ActivityDetailsRes { private List activityImgs; public static ActivityDetailsRes of(Activity activity) { + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM월 dd일 EEEE", new Locale("ko", "KR")); + return ActivityDetailsRes.builder() .id(activity.getId()) .title(activity.getTitle()) .agency(activity.getAgency()) .agency(activity.getAgencyType().getDescription()) .location(activity.getLocation()) - .time(activity.getTime()) + .time(activity.getTime().format(formatter)) .currentParticipants(activity.getCurrentParticipants()) .maxParticipants(activity.getMaxParticipants()) .personalities(activity.getPersonalities()) diff --git a/src/main/java/com/meetup/teame/backend/domain/activity/dto/response/ActivitySummaryRes.java b/src/main/java/com/meetup/teame/backend/domain/activity/dto/response/ActivitySummaryRes.java index 3a61c85..0f84b76 100644 --- a/src/main/java/com/meetup/teame/backend/domain/activity/dto/response/ActivitySummaryRes.java +++ b/src/main/java/com/meetup/teame/backend/domain/activity/dto/response/ActivitySummaryRes.java @@ -1,14 +1,13 @@ package com.meetup.teame.backend.domain.activity.dto.response; import com.meetup.teame.backend.domain.activity.entity.Activity; -import com.meetup.teame.backend.domain.like.repository.ActivityLikeRepository; -import jakarta.persistence.GeneratedValue; -import jakarta.persistence.GenerationType; import lombok.*; -import org.hibernate.annotations.Comment; -import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; import java.util.List; +import java.util.Locale; + +import static java.time.format.DateTimeFormatter.ofPattern; @RequiredArgsConstructor @AllArgsConstructor @@ -26,7 +25,7 @@ public class ActivitySummaryRes { private String location; - private LocalDateTime time; + private String time; private String activityThumbnail; @@ -41,12 +40,14 @@ public static ActivitySummaryRes of(Activity activity, boolean isLiked) { activityThumbnail = activityImgs.get(0); } + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM월 dd일 EEEE", new Locale("ko", "KR")); + return ActivitySummaryRes.builder() .id(activity.getId()) .title(activity.getTitle()) .agency(activity.getAgency()) .agencyType(activity.getAgencyType().getDescription()) - .time(activity.getTime()) + .time(activity.getTime().format(formatter)) .activityThumbnail(activityThumbnail) .isLiked(isLiked) .build(); diff --git a/src/main/java/com/meetup/teame/backend/domain/activity/dto/response/ReadMainActivityRes.java b/src/main/java/com/meetup/teame/backend/domain/activity/dto/response/ReadMainActivityRes.java index 4e23d1a..f14adab 100644 --- a/src/main/java/com/meetup/teame/backend/domain/activity/dto/response/ReadMainActivityRes.java +++ b/src/main/java/com/meetup/teame/backend/domain/activity/dto/response/ReadMainActivityRes.java @@ -1,11 +1,9 @@ package com.meetup.teame.backend.domain.activity.dto.response; -import com.fasterxml.jackson.annotation.JsonFormat; import com.meetup.teame.backend.domain.activity.entity.Activity; import com.meetup.teame.backend.domain.personality.Personality; import lombok.*; -import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.util.List; import java.util.Locale; diff --git a/src/main/java/com/meetup/teame/backend/domain/review/repository/custom/ReviewRepositoryImpl.java b/src/main/java/com/meetup/teame/backend/domain/review/repository/custom/ReviewRepositoryImpl.java index 00a956e..f4d9699 100644 --- a/src/main/java/com/meetup/teame/backend/domain/review/repository/custom/ReviewRepositoryImpl.java +++ b/src/main/java/com/meetup/teame/backend/domain/review/repository/custom/ReviewRepositoryImpl.java @@ -19,6 +19,8 @@ public class ReviewRepositoryImpl implements ReviewRepositoryCustom { public List findReviewsByUserId(Long userId, String type) { BooleanBuilder builder = new BooleanBuilder(); + builder.and(experience.user.id.eq(userId)); + if (type != null) { builder.and(experience.type.eq(ExperienceType.of(type))); } @@ -27,7 +29,7 @@ public List findReviewsByUserId(Long userId, String type) { .selectFrom(review) .join(review.mentor, experience) .fetchJoin() - .where(experience.user.id.eq(userId)) + .where(builder) .fetch(); } diff --git a/src/main/java/com/meetup/teame/backend/domain/user/controller/UserController.java b/src/main/java/com/meetup/teame/backend/domain/user/controller/UserController.java index c7f4bbf..76ab944 100644 --- a/src/main/java/com/meetup/teame/backend/domain/user/controller/UserController.java +++ b/src/main/java/com/meetup/teame/backend/domain/user/controller/UserController.java @@ -70,7 +70,7 @@ public ResponseEntity getUserInfo() { @Operation(summary = "사용자 기본 정보 수정", description = """ 사용자의 기본 정보를 수정하는 api입니다. - 추후 로그인 적용 시에는 jwt토큰도 같이 전달해서 요청해주셔야 합니다. + name, email, imageUrl, location 데이터를 받습니다. """) //기본 정보 수정 @PutMapping("/info") @@ -82,7 +82,9 @@ public ResponseEntity updateUserInfo(@RequestBody UpdateUserReq req @Operation(summary = "내 후기 목록 조회", description = """ 내 후기 목록을 조회하는 api입니다. + 경험 활동 유형을 param으로 보낼 수 있습니다. + 변수명은 type입니다. """) //내 후기 목록 조회 @GetMapping("/reviews") @@ -91,7 +93,11 @@ public ResponseEntity> getMyReviews(@RequestParam String type) { return ResponseEntity.ok().body(myReviews); } - //내 활동 목록 조회(활동은 Activity가 아니라 GroupChatRoom) + @Operation(summary = "내 활동 참여 목록 조회", description = """ + 내 활동 참여 목록을 조회하는 api입니다. + + api 요청 시 보낼 데이터는 token 이외에 없습니다. + """) @GetMapping("/activities") public ResponseEntity> getMyActivities() { List myActivities = userService.getMyActivities(); diff --git a/src/main/java/com/meetup/teame/backend/domain/user/dto/request/UpdateUserReq.java b/src/main/java/com/meetup/teame/backend/domain/user/dto/request/UpdateUserReq.java index bf28336..3235f25 100644 --- a/src/main/java/com/meetup/teame/backend/domain/user/dto/request/UpdateUserReq.java +++ b/src/main/java/com/meetup/teame/backend/domain/user/dto/request/UpdateUserReq.java @@ -13,8 +13,6 @@ public class UpdateUserReq { private String email; - private String password; - private String imageUrl; private String location; From b99356dfd5c1840f88360c2364d155496f76259a Mon Sep 17 00:00:00 2001 From: Jeongho Date: Fri, 17 May 2024 18:13:48 +0900 Subject: [PATCH 4/4] =?UTF-8?q?Fix:=20=EB=82=B4=20=ED=9B=84=EA=B8=B0=20dto?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../review/dto/response/MyReviewRes.java | 53 +++++++++++++++++++ .../domain/review/dto/response/ReviewRes.java | 39 +++++++++----- .../domain/review/service/ReviewService.java | 1 + .../user/controller/UserController.java | 5 +- .../domain/user/service/UserService.java | 7 +-- 5 files changed, 88 insertions(+), 17 deletions(-) create mode 100644 src/main/java/com/meetup/teame/backend/domain/review/dto/response/MyReviewRes.java diff --git a/src/main/java/com/meetup/teame/backend/domain/review/dto/response/MyReviewRes.java b/src/main/java/com/meetup/teame/backend/domain/review/dto/response/MyReviewRes.java new file mode 100644 index 0000000..5887ce4 --- /dev/null +++ b/src/main/java/com/meetup/teame/backend/domain/review/dto/response/MyReviewRes.java @@ -0,0 +1,53 @@ +package com.meetup.teame.backend.domain.review.dto.response; + +import com.meetup.teame.backend.domain.review.entity.Review; +import com.meetup.teame.backend.domain.user.entity.User; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@NoArgsConstructor +@AllArgsConstructor +@Getter +@Builder +public class MyReviewRes { + private Long id; + + private Long menteeId; + + private String menteeName; + + private Long age; + + private String gender; + + private String location; + + private String time; + + private String imageUrl; + + private String experienceType; + + private String title; + + private String description; + + public static MyReviewRes of(Review review) { + User mentee = review.getMentee().getMentee(); + + return MyReviewRes.builder() + .id(review.getId()) + .menteeId(mentee.getId()) + .menteeName(mentee.getName()) + .age(mentee.getAge()) + .gender(mentee.getGender().getDescription()) + .location(mentee.getLocation()) + .imageUrl(mentee.getImageUrl()) + .experienceType(review.getMentor().getType().getDescription()) + .title(review.getMentor().getDescription()) + .description(review.getDescription()) + .build(); + } +} diff --git a/src/main/java/com/meetup/teame/backend/domain/review/dto/response/ReviewRes.java b/src/main/java/com/meetup/teame/backend/domain/review/dto/response/ReviewRes.java index 2f23844..2fc498c 100644 --- a/src/main/java/com/meetup/teame/backend/domain/review/dto/response/ReviewRes.java +++ b/src/main/java/com/meetup/teame/backend/domain/review/dto/response/ReviewRes.java @@ -1,16 +1,11 @@ package com.meetup.teame.backend.domain.review.dto.response; -import com.meetup.teame.backend.domain.chatroom.entity.DirectChatRoom; -import com.meetup.teame.backend.domain.experience.entity.Experience; import com.meetup.teame.backend.domain.review.entity.Review; -import jakarta.persistence.FetchType; -import jakarta.persistence.JoinColumn; -import jakarta.persistence.ManyToOne; +import com.meetup.teame.backend.domain.user.entity.User; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; -import org.hibernate.annotations.Comment; @NoArgsConstructor @AllArgsConstructor @@ -20,20 +15,40 @@ public class ReviewRes { private Long id; - private String description; - private Long mentorId; - private Long menteeId; + private String mentorName; + + private Long age; + + private String gender; + + private String location; + + private String time; - //멘토 이름, 나이, 성별, 거주지, 프로필 사진, 경험 유형, 경험 제목 + private String imageUrl; + + private String experienceType; + + private String title; + + private String description; public static ReviewRes of(Review review) { + User mentor = review.getMentor().getUser(); + return ReviewRes.builder() .id(review.getId()) + .mentorId(mentor.getId()) + .mentorName(mentor.getName()) + .age(mentor.getAge()) + .gender(mentor.getGender().getDescription()) + .location(mentor.getLocation()) + .imageUrl(mentor.getImageUrl()) + .experienceType(review.getMentor().getType().getDescription()) + .title(review.getMentor().getDescription()) .description(review.getDescription()) - .mentorId(review.getMentor().getUser().getId()) - .menteeId(review.getMentee().getMentee().getId()) .build(); } } diff --git a/src/main/java/com/meetup/teame/backend/domain/review/service/ReviewService.java b/src/main/java/com/meetup/teame/backend/domain/review/service/ReviewService.java index 8dd4e16..5dc7218 100644 --- a/src/main/java/com/meetup/teame/backend/domain/review/service/ReviewService.java +++ b/src/main/java/com/meetup/teame/backend/domain/review/service/ReviewService.java @@ -33,6 +33,7 @@ public ReviewRes createReview(CreateReviewReq createReviewReq) { Review review = reviewRepository.save(Review.of(createReviewReq.getDescription(), mentor, mentee)); + return ReviewRes.of(review); } diff --git a/src/main/java/com/meetup/teame/backend/domain/user/controller/UserController.java b/src/main/java/com/meetup/teame/backend/domain/user/controller/UserController.java index 36c4c1d..6dcc249 100644 --- a/src/main/java/com/meetup/teame/backend/domain/user/controller/UserController.java +++ b/src/main/java/com/meetup/teame/backend/domain/user/controller/UserController.java @@ -1,6 +1,7 @@ package com.meetup.teame.backend.domain.user.controller; import com.meetup.teame.backend.domain.activity.dto.response.ActivitySummaryRes; +import com.meetup.teame.backend.domain.review.dto.response.MyReviewRes; import com.meetup.teame.backend.domain.review.dto.response.ReviewRes; import com.meetup.teame.backend.domain.user.dto.request.OnboardingReq; import com.meetup.teame.backend.domain.user.dto.request.ReadCalenderReq; @@ -110,8 +111,8 @@ public ResponseEntity updateUserInfo(@RequestBody UpdateUserReq req """) //내 후기 목록 조회 @GetMapping("/reviews") - public ResponseEntity> getMyReviews(@RequestParam String type) { - List myReviews = userService.getMyReviews(type); + public ResponseEntity> getMyReviews(@RequestParam String type) { + List myReviews = userService.getMyReviews(type); return ResponseEntity.ok().body(myReviews); } diff --git a/src/main/java/com/meetup/teame/backend/domain/user/service/UserService.java b/src/main/java/com/meetup/teame/backend/domain/user/service/UserService.java index e0e796a..2b1524b 100644 --- a/src/main/java/com/meetup/teame/backend/domain/user/service/UserService.java +++ b/src/main/java/com/meetup/teame/backend/domain/user/service/UserService.java @@ -14,6 +14,7 @@ import com.meetup.teame.backend.domain.experience.repository.ExperienceRepository; import com.meetup.teame.backend.domain.like.repository.ActivityLikeRepository; import com.meetup.teame.backend.domain.personality.Personality; +import com.meetup.teame.backend.domain.review.dto.response.MyReviewRes; import com.meetup.teame.backend.domain.review.dto.response.ReviewRes; import com.meetup.teame.backend.domain.review.entity.Review; import com.meetup.teame.backend.domain.review.repository.ReviewRepository; @@ -104,11 +105,11 @@ public UserInfoRes updateUserInfo(UpdateUserReq request) { } //내 후기 조회 - public List getMyReviews(String type) { + public List getMyReviews(String type) { Long userId = SecurityContextProvider.getAuthenticatedUserId(); List myReviews = reviewRepository.findReviewsByUserId(userId, type); - List reviews = myReviews.stream() - .map(ReviewRes::of) + List reviews = myReviews.stream() + .map(MyReviewRes::of) .toList(); return reviews; }