|
3 | 3 | import com.back.domain.post.post.entity.Post; |
4 | 4 | import com.back.domain.post.post.entity.PostImage; |
5 | 5 | import com.back.domain.post.post.entity.PostLike; |
| 6 | +import com.back.domain.post.post.enums.PostStatus; |
6 | 7 | import lombok.Builder; |
7 | 8 | import lombok.Getter; |
8 | 9 |
|
|
13 | 14 | @Builder |
14 | 15 | public class MyHistoryLikedPostItemDto { |
15 | 16 | private Long id; |
| 17 | + private Long postId; |
| 18 | + private String categoryName; |
| 19 | + private String userNickName; |
16 | 20 | private String title; |
| 21 | + private String content; |
17 | 22 | private List<String> imageUrls; |
18 | | - private LocalDateTime likedAt; |
| 23 | + private LocalDateTime createdAt; |
| 24 | + private LocalDateTime updatedAt; |
| 25 | + private PostStatus status; |
19 | 26 | private Integer likeCount; |
20 | 27 | private Integer commentCount; |
| 28 | + private Integer viewCount; |
| 29 | + private LocalDateTime likedAt; |
21 | 30 |
|
22 | 31 | public static MyHistoryLikedPostItemDto from(PostLike pl) { |
23 | 32 | 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 | + |
24 | 39 | 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) |
26 | 44 | .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()) |
31 | 50 | .likeCount(p.getLikeCount()) |
32 | 51 | .commentCount(p.getCommentCount()) |
| 52 | + .viewCount(p.getViewCount()) |
| 53 | + .likedAt(pl.getCreatedAt()) |
33 | 54 | .build(); |
34 | 55 | } |
35 | 56 | } |
|
0 commit comments