Skip to content

Commit 28d284e

Browse files
committed
refactor: MyHistoryLikedPostItemDto에 상세 필드 및 로직 개선 추가
1 parent c382566 commit 28d284e

File tree

1 file changed

+27
-6
lines changed

1 file changed

+27
-6
lines changed

src/main/java/com/back/domain/myhistory/dto/MyHistoryLikedPostItemDto.java

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import com.back.domain.post.post.entity.Post;
44
import com.back.domain.post.post.entity.PostImage;
55
import com.back.domain.post.post.entity.PostLike;
6+
import com.back.domain.post.post.enums.PostStatus;
67
import lombok.Builder;
78
import lombok.Getter;
89

@@ -13,23 +14,43 @@
1314
@Builder
1415
public class MyHistoryLikedPostItemDto {
1516
private Long id;
17+
private Long postId;
18+
private String categoryName;
19+
private String userNickName;
1620
private String title;
21+
private String content;
1722
private List<String> imageUrls;
18-
private LocalDateTime likedAt;
23+
private LocalDateTime createdAt;
24+
private LocalDateTime updatedAt;
25+
private PostStatus status;
1926
private Integer likeCount;
2027
private Integer commentCount;
28+
private Integer viewCount;
29+
private LocalDateTime likedAt;
2130

2231
public static MyHistoryLikedPostItemDto from(PostLike pl) {
2332
Post p = pl.getPost();
33+
List<String> imageUrls = p.getImages() == null
34+
? List.of()
35+
: p.getImages().stream()
36+
.map(PostImage::getUrl)
37+
.toList();
38+
2439
return MyHistoryLikedPostItemDto.builder()
25-
.id(p.getId())
40+
.id(pl.getId())
41+
.postId(p.getId())
42+
.categoryName(p.getCategory() != null ? p.getCategory().getName() : null)
43+
.userNickName(p.getUser() != null ? p.getUser().getNickname() : null)
2644
.title(p.getTitle())
27-
.imageUrls(p.getImages().stream()
28-
.map(PostImage::getUrl)
29-
.toList())
30-
.likedAt(pl.getCreatedAt())
45+
.content(p.getContent())
46+
.imageUrls(imageUrls)
47+
.createdAt(p.getCreatedAt())
48+
.updatedAt(p.getUpdatedAt())
49+
.status(p.getStatus())
3150
.likeCount(p.getLikeCount())
3251
.commentCount(p.getCommentCount())
52+
.viewCount(p.getViewCount())
53+
.likedAt(pl.getCreatedAt())
3354
.build();
3455
}
3556
}

0 commit comments

Comments
 (0)