Skip to content

Commit 961d9fa

Browse files
authored
[refactor] 내활동: 내가 작성한 게시글 응답 DTO 필드 추가 #284 (#286)
* Revert "chore: initData용 이미지 추가" This reverts commit ef30eef. * . * fix: 삭제되지 않은 댓글만 조회하는 기능 추가 * chore: 수정사항 없음 * feat: MyHistoryPostItemDto에 상세 정보 필드 추가 및 매핑 로직 업데이트
1 parent 85003be commit 961d9fa

File tree

2 files changed

+22
-5
lines changed

2 files changed

+22
-5
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
@@ -2,33 +2,49 @@
22

33
import com.back.domain.post.post.entity.Post;
44
import com.back.domain.post.post.entity.PostImage;
5-
import java.util.List;
5+
import com.back.domain.post.post.enums.PostStatus;
66
import lombok.Builder;
77
import lombok.Getter;
88

99
import java.time.LocalDateTime;
10+
import java.util.List;
1011

1112
@Getter
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-

src/main/java/com/back/domain/post/comment/repository/CommentRepository.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22

33
import com.back.domain.post.comment.entity.Comment;
44
import com.back.domain.post.comment.enums.CommentStatus;
5-
import java.util.List;
65
import org.springframework.data.jpa.repository.JpaRepository;
76
import org.springframework.stereotype.Repository;
87

8+
import java.util.List;
9+
910
@Repository
1011
public interface CommentRepository extends JpaRepository<Comment, Long> {
1112

0 commit comments

Comments
 (0)