Skip to content

Commit

Permalink
Merge pull request #228 from Donggrina/hotfix/fix_story_find
Browse files Browse the repository at this point in the history
스토리 조회 수정
  • Loading branch information
Kwonminwoo authored Jun 20, 2024
2 parents 65f8f8a + fa54ae2 commit ea3898e
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -9,13 +10,15 @@ public record StoryFindListResponse(
Long diaryId,
String authorImage,
String author,
List<String> petImages,
String weather,
String authorGroup,
List<String> images,
String content,
int commentCount,
int favoriteCount,
boolean favoriteState,
LocalDateTime createdDate,
LocalDate date,
boolean isMyStory
) {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
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;

@Builder
public record StoryFindResponse(
String authorImage,
String author,
List<String> petImages,
String weather,
String authorGroup,
List<String> images,
String content,
LocalDateTime createdDate,
LocalDate date,
boolean favoriteState,
int favoriteCount,
List<CommentFindResponse> comments
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,21 @@ public StoryFindResponse findStory(Long diaryId, Long memberId) {
.toList();
}

List<String> 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)
Expand All @@ -136,18 +143,24 @@ public StoryFindListPage findStories(Long memberId, Pageable pageable) {
commentCount += comment.getChildren().size();
}

List<String> 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();
})
Expand Down

0 comments on commit ea3898e

Please sign in to comment.