From fa54ae2bc4646c8dab67f09cc2d50ad182fa2b4f Mon Sep 17 00:00:00 2001 From: kwonMInwoo Date: Thu, 20 Jun 2024 14:13:52 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=EC=8A=A4=ED=86=A0=EB=A6=AC=20=EC=A1=B0?= =?UTF-8?q?=ED=9A=8C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 데이터 추가 --- .../dto/response/StoryFindListResponse.java | 5 ++++- .../story/dto/response/StoryFindResponse.java | 6 +++++- .../domain/story/service/StoryService.java | 17 +++++++++++++++-- 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/codeit/donggrina/domain/story/dto/response/StoryFindListResponse.java b/src/main/java/com/codeit/donggrina/domain/story/dto/response/StoryFindListResponse.java index a76b87d..ca955bd 100644 --- a/src/main/java/com/codeit/donggrina/domain/story/dto/response/StoryFindListResponse.java +++ b/src/main/java/com/codeit/donggrina/domain/story/dto/response/StoryFindListResponse.java @@ -1,5 +1,6 @@ package com.codeit.donggrina.domain.story.dto.response; +import java.time.LocalDate; import java.time.LocalDateTime; import java.util.List; import lombok.Builder; @@ -9,13 +10,15 @@ public record StoryFindListResponse( Long diaryId, String authorImage, String author, + List petImages, + String weather, String authorGroup, List images, String content, int commentCount, int favoriteCount, boolean favoriteState, - LocalDateTime createdDate, + LocalDate date, boolean isMyStory ) { diff --git a/src/main/java/com/codeit/donggrina/domain/story/dto/response/StoryFindResponse.java b/src/main/java/com/codeit/donggrina/domain/story/dto/response/StoryFindResponse.java index 1cfe7be..4c07a92 100644 --- a/src/main/java/com/codeit/donggrina/domain/story/dto/response/StoryFindResponse.java +++ b/src/main/java/com/codeit/donggrina/domain/story/dto/response/StoryFindResponse.java @@ -1,6 +1,7 @@ package com.codeit.donggrina.domain.story.dto.response; import com.codeit.donggrina.domain.comment.dto.response.CommentFindResponse; +import java.time.LocalDate; import java.time.LocalDateTime; import java.util.List; import lombok.Builder; @@ -8,10 +9,13 @@ @Builder public record StoryFindResponse( String authorImage, + String author, + List petImages, + String weather, String authorGroup, List images, String content, - LocalDateTime createdDate, + LocalDate date, boolean favoriteState, int favoriteCount, List comments diff --git a/src/main/java/com/codeit/donggrina/domain/story/service/StoryService.java b/src/main/java/com/codeit/donggrina/domain/story/service/StoryService.java index b5e34c8..a02ffb0 100644 --- a/src/main/java/com/codeit/donggrina/domain/story/service/StoryService.java +++ b/src/main/java/com/codeit/donggrina/domain/story/service/StoryService.java @@ -107,14 +107,21 @@ public StoryFindResponse findStory(Long diaryId, Long memberId) { .toList(); } + List petImages = foundStory.getDiaryPets().stream() + .map(diaryPet -> diaryPet.getPet().getProfileImage().getUrl()) + .toList(); + Member author = foundStory.getMember(); return StoryFindResponse.builder() .authorImage(author.getProfileImage().getUrl()) + .author(author.getName()) + .petImages(petImages) + .weather(foundStory.getWeather()) .authorGroup(author.getGroup().getName()) .images(images) .content(foundStory.getContent()) - .createdDate(foundStory.getCreatedAt()) + .date(foundStory.getDate()) .favoriteState(heartOptional.isPresent()) .favoriteCount(foundStory.getHeartCount()) .comments(comments) @@ -136,18 +143,24 @@ public StoryFindListPage findStories(Long memberId, Pageable pageable) { commentCount += comment.getChildren().size(); } + List petImages = diary.getDiaryPets().stream() + .map(diaryPet -> diaryPet.getPet().getProfileImage().getUrl()) + .toList(); + Member author = diary.getMember(); return StoryFindListResponse.builder() .diaryId(diary.getId()) .authorImage(author.getProfileImage().getUrl()) .author(author.getName()) + .petImages(petImages) + .weather(diary.getWeather()) .authorGroup(author.getGroup().getName()) .images(images) .content(diary.getContent()) .commentCount(commentCount) .favoriteCount(diary.getHeartCount()) - .createdDate(diary.getCreatedAt()) + .date(diary.getDate()) .isMyStory(author.getId().equals(memberId)) .build(); })