-
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 branch 'feat/#60' into develop
# Conflicts: # outbound/src/main/java/com/pocket/outbound/repository/album/AlbumRepository.java
- Loading branch information
Showing
18 changed files
with
258 additions
and
14 deletions.
There are no files selected for viewing
9 changes: 9 additions & 0 deletions
9
domain/src/main/java/com/pocket/domain/dto/photobooth/PhotoBoothVisitedDto.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,9 @@ | ||
package com.pocket.domain.dto.photobooth; | ||
|
||
public record PhotoBoothVisitedDto( | ||
Long photoboothId, | ||
String name, | ||
Integer month, | ||
Integer date | ||
) { | ||
} |
11 changes: 11 additions & 0 deletions
11
domain/src/main/java/com/pocket/domain/dto/review/ReviewMypageDetailDto.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,11 @@ | ||
package com.pocket.domain.dto.review; | ||
|
||
public record ReviewMypageDetailDto( | ||
Long reviewId, | ||
String imageUrl, | ||
Integer month, | ||
Integer date, | ||
String photoboothName, | ||
Double rating | ||
) { | ||
} |
9 changes: 9 additions & 0 deletions
9
domain/src/main/java/com/pocket/domain/dto/review/ReviewMypageDto.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,9 @@ | ||
package com.pocket.domain.dto.review; | ||
|
||
import java.util.List; | ||
|
||
public record ReviewMypageDto( | ||
int reviewCount, | ||
List<ReviewMypageDetailDto> reviewMypageDetailDtoList | ||
) { | ||
} |
11 changes: 11 additions & 0 deletions
11
domain/src/main/java/com/pocket/domain/port/photobooth/PhotoBoothVisitedPort.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,11 @@ | ||
package com.pocket.domain.port.photobooth; | ||
|
||
import com.pocket.domain.dto.photobooth.PhotoBoothVisitedDto; | ||
|
||
import java.util.List; | ||
|
||
public interface PhotoBoothVisitedPort { | ||
|
||
List<PhotoBoothVisitedDto> getVisitedPhotoBooths(String userEmail); | ||
|
||
} |
9 changes: 9 additions & 0 deletions
9
domain/src/main/java/com/pocket/domain/port/review/ReviewMypagePort.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,9 @@ | ||
package com.pocket.domain.port.review; | ||
|
||
import com.pocket.domain.dto.review.ReviewMypageDto; | ||
|
||
public interface ReviewMypagePort { | ||
|
||
ReviewMypageDto reviewMypage(String userEmail); | ||
|
||
} |
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
11 changes: 11 additions & 0 deletions
11
domain/src/main/java/com/pocket/domain/usecase/photobooth/PhotoBoothVisitedUseCase.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,11 @@ | ||
package com.pocket.domain.usecase.photobooth; | ||
|
||
import com.pocket.domain.dto.photobooth.PhotoBoothVisitedDto; | ||
|
||
import java.util.List; | ||
|
||
public interface PhotoBoothVisitedUseCase { | ||
|
||
List<PhotoBoothVisitedDto> getVisitedPhotoBooths(String userEmail); | ||
|
||
} |
9 changes: 9 additions & 0 deletions
9
domain/src/main/java/com/pocket/domain/usecase/review/ReviewMypageUseCase.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,9 @@ | ||
package com.pocket.domain.usecase.review; | ||
|
||
import com.pocket.domain.dto.review.ReviewMypageDto; | ||
|
||
public interface ReviewMypageUseCase { | ||
|
||
ReviewMypageDto reviewMypage(String userEmail); | ||
|
||
} |
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
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
54 changes: 54 additions & 0 deletions
54
...rc/main/java/com/pocket/outbound/adapter/photobooth/adapter/PhotoBoothVisitedAdapter.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,54 @@ | ||
package com.pocket.outbound.adapter.photobooth.adapter; | ||
|
||
import com.pocket.core.aop.annotation.AdapterService; | ||
import com.pocket.domain.dto.photobooth.PhotoBoothVisitedDto; | ||
import com.pocket.domain.port.photobooth.PhotoBoothVisitedPort; | ||
import com.pocket.outbound.entity.album.JpaAlbum; | ||
import com.pocket.outbound.entity.photobooth.JpaPhotoBooth; | ||
import com.pocket.outbound.entity.review.JpaReview; | ||
import com.pocket.outbound.repository.album.AlbumRepository; | ||
import com.pocket.outbound.repository.review.ReviewRepository; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
import java.time.LocalDate; | ||
import java.util.List; | ||
import java.util.Set; | ||
import java.util.stream.Collectors; | ||
|
||
@AdapterService | ||
@RequiredArgsConstructor | ||
public class PhotoBoothVisitedAdapter implements PhotoBoothVisitedPort { | ||
|
||
private final AlbumRepository albumRepository; | ||
private final ReviewRepository reviewRepository; | ||
|
||
@Override | ||
public List<PhotoBoothVisitedDto> getVisitedPhotoBooths(String userEmail) { | ||
List<JpaAlbum> allAlbums = albumRepository.findByJpaUser_User_Email(userEmail); | ||
List<JpaReview> allReviews = reviewRepository.findByJpaUser_User_Email(userEmail); | ||
|
||
// 모든 JpaPhotoBooth를 추출하여 Set으로 변환 | ||
Set<JpaPhotoBooth> reviewPhotoBooths = allReviews.stream() | ||
.map(JpaReview::getPhotoBooth) | ||
.collect(Collectors.toSet()); | ||
|
||
// allAlbums에서 reviewPhotoBooths에 없는 JpaPhotoBooth만 필터링하여 리스트로 수집 | ||
List<PhotoBoothVisitedDto> photoBoothVisitedDtos = allAlbums.stream() | ||
.filter(album -> !reviewPhotoBooths.contains(album.getPhotoBooth())) | ||
.map(album -> { | ||
JpaPhotoBooth jpaPhotoBooth = album.getPhotoBooth(); | ||
Long photoboothId = jpaPhotoBooth.getId(); | ||
String name = jpaPhotoBooth.getPhotoBooth().getName(); | ||
|
||
// JpaAlbum의 createdAt 필드에서 월과 일 정보 추출 | ||
LocalDate createdAt = album.getImage().getCreatedAt().toLocalDate(); | ||
Integer month = createdAt.getMonthValue(); | ||
Integer date = createdAt.getDayOfMonth(); | ||
|
||
return new PhotoBoothVisitedDto(photoboothId, name, month, date); | ||
}) | ||
.collect(Collectors.toList()); | ||
|
||
return photoBoothVisitedDtos; | ||
} | ||
} |
51 changes: 51 additions & 0 deletions
51
outbound/src/main/java/com/pocket/outbound/adapter/review/adapter/ReviewMypageAdapter.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.pocket.outbound.adapter.review.adapter; | ||
|
||
|
||
import com.pocket.core.aop.annotation.AdapterService; | ||
import com.pocket.domain.dto.review.ReviewMypageDetailDto; | ||
import com.pocket.domain.dto.review.ReviewMypageDto; | ||
import com.pocket.domain.port.review.ReviewMypagePort; | ||
import com.pocket.outbound.entity.review.JpaReview; | ||
import com.pocket.outbound.entity.review.JpaReviewImage; | ||
import com.pocket.outbound.repository.review.ReviewImageRepository; | ||
import com.pocket.outbound.repository.review.ReviewRepository; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Optional; | ||
|
||
import static com.amazonaws.services.ec2.model.ResourceType.Image; | ||
|
||
@AdapterService | ||
@RequiredArgsConstructor | ||
public class ReviewMypageAdapter implements ReviewMypagePort { | ||
|
||
private final ReviewRepository reviewRepository; | ||
private final ReviewImageRepository reviewImageRepository; | ||
|
||
@Override | ||
public ReviewMypageDto reviewMypage(String userEmail) { | ||
List<JpaReview> jpaReviews = reviewRepository.findByJpaUser_User_Email(userEmail); | ||
|
||
List<ReviewMypageDetailDto> reviewMypageDetailDtos = new ArrayList<>(); | ||
|
||
for (JpaReview jpaReview : jpaReviews) { | ||
|
||
JpaReviewImage reviewImage = reviewImageRepository.findTop1ByReviewIdOrderByReviewIdDesc(jpaReview.getId()); | ||
String imageUrl = (reviewImage != null && reviewImage.getImage() != null) ? reviewImage.getImage().getImageUrl() : ""; | ||
|
||
|
||
reviewMypageDetailDtos.add(new ReviewMypageDetailDto( | ||
jpaReview.getId(), | ||
imageUrl, | ||
jpaReview.getReview().getCreatedAt().getMonthValue(), | ||
jpaReview.getReview().getCreatedAt().getDayOfMonth(), | ||
jpaReview.getPhotoBooth().getPhotoBooth().getName(), | ||
jpaReview.getPhotoBooth().getRating().doubleValue() | ||
)); | ||
} | ||
|
||
return new ReviewMypageDto(jpaReviews.size(), reviewMypageDetailDtos); | ||
} | ||
} |
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
Oops, something went wrong.