-
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.
Merge pull request #52 from Kusitms-29th-Meetup-TeamE/feat/44/experie…
…nce-detail Feat: 배움나누기 상세 api 구현
- Loading branch information
Showing
6 changed files
with
148 additions
and
1 deletion.
There are no files selected for viewing
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
51 changes: 51 additions & 0 deletions
51
...in/java/com/meetup/teame/backend/domain/experience/dto/response/ExperienceReviewsRes.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,51 @@ | ||
package com.meetup.teame.backend.domain.experience.dto.response; | ||
|
||
import com.fasterxml.jackson.annotation.JsonFormat; | ||
import com.meetup.teame.backend.domain.experience.entity.ExperienceType; | ||
import com.meetup.teame.backend.domain.review.entity.Review; | ||
import com.meetup.teame.backend.domain.user.entity.User; | ||
import lombok.*; | ||
|
||
import java.time.LocalDate; | ||
import java.util.List; | ||
|
||
@AllArgsConstructor(access = AccessLevel.PRIVATE) | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
@Getter | ||
@Builder | ||
public class ExperienceReviewsRes { | ||
@AllArgsConstructor(access = AccessLevel.PRIVATE) | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
@Getter | ||
@Builder | ||
public static class ExperienceReview { | ||
private String title; | ||
private String content; | ||
private String name; | ||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy.MM.dd") | ||
private LocalDate date; | ||
|
||
public static ExperienceReview of(Review review) { | ||
return ExperienceReview.builder() | ||
.title(review.getAppointmentTitle()) | ||
.content(review.getContent()) | ||
.name(review.getMentee().getName()) | ||
.date(review.getReviewDate()) | ||
.build(); | ||
} | ||
} | ||
|
||
private String type; | ||
private List<ExperienceReview> reviews; | ||
|
||
public static ExperienceReviewsRes of(ExperienceType type, User mentor) { | ||
List<ExperienceReview> reviews = mentor.getReviewsAboutMe().stream() | ||
.filter(review -> review.getAppointmentType().equals(type)) | ||
.map(ExperienceReview::of) | ||
.toList(); | ||
return ExperienceReviewsRes.builder() | ||
.type(type.getDescription()) | ||
.reviews(reviews) | ||
.build(); | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
src/main/java/com/meetup/teame/backend/domain/experience/dto/response/OtherExperience.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,20 @@ | ||
package com.meetup.teame.backend.domain.experience.dto.response; | ||
|
||
import com.meetup.teame.backend.domain.experience.entity.Experience; | ||
import lombok.*; | ||
|
||
@AllArgsConstructor(access = AccessLevel.PRIVATE) | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
@Getter | ||
@Builder | ||
public class OtherExperience { | ||
private String type; | ||
private String title; | ||
|
||
public static OtherExperience of(Experience experience) { | ||
return OtherExperience.builder() | ||
.type(experience.getType().getDescription()) | ||
.title(experience.getDescription()) | ||
.build(); | ||
} | ||
} |
52 changes: 52 additions & 0 deletions
52
...java/com/meetup/teame/backend/domain/experience/dto/response/ReadExperienceDetailRes.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,52 @@ | ||
package com.meetup.teame.backend.domain.experience.dto.response; | ||
|
||
import com.meetup.teame.backend.domain.experience.entity.Experience; | ||
import com.meetup.teame.backend.domain.user.entity.User; | ||
import lombok.*; | ||
|
||
import java.util.List; | ||
|
||
@AllArgsConstructor(access = AccessLevel.PRIVATE) | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
@Getter | ||
@Builder | ||
public class ReadExperienceDetailRes { | ||
private String imageUrl; | ||
private String name; | ||
private Long age; | ||
private String gender; | ||
private String location; | ||
private String oneWord; | ||
private String title; | ||
private String content; | ||
private List<ExperienceReviewsRes> reviews; | ||
private List<OtherExperience> otherExperiences; | ||
|
||
public static ReadExperienceDetailRes of(Experience experience) { | ||
User user = experience.getUser(); | ||
|
||
List<ExperienceReviewsRes> reviews = user.getExperiences().stream() | ||
.map(Experience::getType) | ||
.distinct() | ||
.map(type -> ExperienceReviewsRes.of(type, user)) | ||
.toList(); | ||
|
||
List<OtherExperience> otherExperiences = user.getExperiences().stream() | ||
.filter(exp -> !exp.getId().equals(experience.getId())) | ||
.map(OtherExperience::of) | ||
.toList(); | ||
|
||
return ReadExperienceDetailRes.builder() | ||
.imageUrl(user.getImageUrl()) | ||
.name(user.getName()) | ||
.age(user.getAge()) | ||
.gender(user.getGender().getDescription()) | ||
.location(user.getLocation()) | ||
.oneWord(user.getOneWord()) | ||
.title(experience.getDescription()) | ||
.content(experience.getDetail()) | ||
.reviews(reviews) | ||
.otherExperiences(otherExperiences) | ||
.build(); | ||
} | ||
} |
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
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