Skip to content

Commit 090d7df

Browse files
committed
feat: MyHistoryPostItemDto에 상세 정보 필드 추가 및 매핑 로직 업데이트
1 parent 23b8f4b commit 090d7df

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

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

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
package com.back.domain.myhistory.dto;
1+
package com.back.domain.myhistory.dto;
22

33
import com.back.domain.post.post.entity.Post;
44
import com.back.domain.post.post.entity.PostImage;
5+
import com.back.domain.post.post.enums.PostStatus;
56
import lombok.Builder;
67
import lombok.Getter;
78

@@ -12,23 +13,38 @@
1213
@Builder
1314
public class MyHistoryPostItemDto {
1415
private Long id;
16+
private Long postId;
17+
private String categoryName;
18+
private String userNickName;
1519
private String title;
20+
private String content;
1621
private List<String> imageUrls;
1722
private LocalDateTime createdAt;
23+
private LocalDateTime updatedAt;
24+
private PostStatus status;
1825
private Integer likeCount;
1926
private Integer commentCount;
27+
private Integer viewCount;
2028

2129
public static MyHistoryPostItemDto from(Post p) {
30+
String categoryName = p.getCategory() != null ? p.getCategory().getName() : null;
31+
String userNickName = p.getUser() != null ? p.getUser().getNickname() : null;
2232
return MyHistoryPostItemDto.builder()
2333
.id(p.getId())
34+
.postId(p.getId())
35+
.categoryName(categoryName)
36+
.userNickName(userNickName)
2437
.title(p.getTitle())
38+
.content(p.getContent())
2539
.imageUrls(p.getImages().stream()
26-
.map(PostImage::getUrl)
27-
.toList())
40+
.map(PostImage::getUrl)
41+
.toList())
2842
.createdAt(p.getCreatedAt())
43+
.updatedAt(p.getUpdatedAt())
44+
.status(p.getStatus())
2945
.likeCount(p.getLikeCount())
3046
.commentCount(p.getCommentCount())
47+
.viewCount(p.getViewCount())
3148
.build();
3249
}
3350
}
34-

0 commit comments

Comments
 (0)