-
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.
Browse files
Browse the repository at this point in the history
Feat/#22/reply 기능 개발
- Loading branch information
Showing
13 changed files
with
268 additions
and
163 deletions.
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
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
14 changes: 4 additions & 10 deletions
14
src/main/java/com/leets/X/domain/post/dto/response/CommentResponseDto.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
14 changes: 4 additions & 10 deletions
14
src/main/java/com/leets/X/domain/post/dto/response/ImageResponseDto.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
46 changes: 46 additions & 0 deletions
46
src/main/java/com/leets/X/domain/post/dto/response/ParentPostResponseDto.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,46 @@ | ||
package com.leets.X.domain.post.dto.response; | ||
|
||
import com.leets.X.domain.post.domain.Post; | ||
import com.leets.X.domain.post.domain.enums.IsDeleted; | ||
import com.leets.X.domain.user.domain.User; | ||
|
||
import java.time.LocalDateTime; | ||
import java.util.Collections; | ||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
public record ParentPostResponseDto( | ||
Long id, | ||
String content, | ||
Integer views, | ||
IsDeleted isDeleted, | ||
LocalDateTime createdAt, | ||
PostUserResponse user, | ||
List<ImageResponseDto> images, | ||
Long likeCount, | ||
Boolean isLikedByUser | ||
) { | ||
public static ParentPostResponseDto from(Post post, boolean isLikedByUser) { | ||
return new ParentPostResponseDto( | ||
post.getId(), | ||
post.getContent(), | ||
post.getViews(), | ||
post.getIsDeleted(), | ||
post.getCreatedAt(), | ||
convertUser(post.getUser()), // User 변환 | ||
convertImagesToDtoList(post), // Images 변환 | ||
post.getLikesCount(), | ||
isLikedByUser // 좋아요 여부 설정 | ||
); | ||
} | ||
|
||
private static PostUserResponse convertUser(User user) { | ||
return user != null ? PostUserResponse.from(user) : null; | ||
} | ||
|
||
private static List<ImageResponseDto> convertImagesToDtoList(Post post) { | ||
return post.getImages() != null ? post.getImages().stream() | ||
.map(ImageResponseDto::from) | ||
.collect(Collectors.toList()) : Collections.emptyList(); | ||
} | ||
} |
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.