diff --git a/src/main/java/ussum/homepage/application/comment/service/dto/response/CommentListResponse.java b/src/main/java/ussum/homepage/application/comment/service/dto/response/CommentListResponse.java index bd07797..198db08 100644 --- a/src/main/java/ussum/homepage/application/comment/service/dto/response/CommentListResponse.java +++ b/src/main/java/ussum/homepage/application/comment/service/dto/response/CommentListResponse.java @@ -11,6 +11,11 @@ public static CommentListResponse of(List postCommentRespon } public void validAuthority(List canAuthorityList) { - postComments.forEach(postComment -> postComment.canAuthority(canAuthorityList)); + postComments.forEach(postComment -> { + postComment.canAuthority(canAuthorityList); + postComment.getPostReplyComments().stream().forEach( + postReplyComment -> postReplyComment.canAuthority(canAuthorityList) + ); + }); } } diff --git a/src/main/java/ussum/homepage/application/comment/service/dto/response/PostCommentResponse.java b/src/main/java/ussum/homepage/application/comment/service/dto/response/PostCommentResponse.java index 01d49a1..d45d1b0 100644 --- a/src/main/java/ussum/homepage/application/comment/service/dto/response/PostCommentResponse.java +++ b/src/main/java/ussum/homepage/application/comment/service/dto/response/PostCommentResponse.java @@ -57,6 +57,7 @@ public static PostCommentResponse of(PostComment postComment, User user, String .createdAt(postComment.getCreatedAt()) .lastEditedAt(postComment.getLastEditedAt()) .likeCount(likeCount) + .isAuthor(isAuthor) .isLiked(isLiked) .isDeleted(postComment.getIsDeleted()) .postReplyComments(postReplyComments) diff --git a/src/main/java/ussum/homepage/application/comment/service/dto/response/PostReplyCommentResponse.java b/src/main/java/ussum/homepage/application/comment/service/dto/response/PostReplyCommentResponse.java index db82e26..2ecfda8 100644 --- a/src/main/java/ussum/homepage/application/comment/service/dto/response/PostReplyCommentResponse.java +++ b/src/main/java/ussum/homepage/application/comment/service/dto/response/PostReplyCommentResponse.java @@ -1,20 +1,39 @@ package ussum.homepage.application.comment.service.dto.response; +import lombok.Builder; import ussum.homepage.domain.comment.PostReplyComment; import ussum.homepage.domain.user.User; -public record PostReplyCommentResponse( - Long id, - String authorName, - String studentId, - String content, - String createdAt, - String lastEditedAt, - Integer likeCount, - Boolean isAuthor, - Boolean isLiked, - Boolean isDeleted -) { +import java.util.List; + +public class PostReplyCommentResponse { + public Long id; + public String authorName; + public String studentId; + public String content; + public String createdAt; + public String lastEditedAt; + public Integer likeCount; + public Boolean isAuthor; + public Boolean isLiked; + public Boolean isDeleted; + public List canAuthority; + + @Builder + public PostReplyCommentResponse(Long id, String authorName, String studentId, String content, String createdAt, String lastEditedAt, Integer likeCount, Boolean isAuthor, Boolean isLiked, Boolean isDeleted, List canAuthority) { + this.id = id; + this.authorName = authorName; + this.studentId = studentId; + this.content = content; + this.createdAt = createdAt; + this.lastEditedAt = lastEditedAt; + this.likeCount = likeCount; + this.isAuthor = isAuthor; + this.isLiked = isLiked; + this.isDeleted = isDeleted; + this.canAuthority = canAuthority; + } + public static PostReplyCommentResponse of(PostReplyComment postReplyComment, User user, Integer likeCount, Boolean isAuthor, Boolean isLiked) { String studentId = user.getStudentId(); String content = postReplyComment.getContent(); @@ -22,17 +41,21 @@ public static PostReplyCommentResponse of(PostReplyComment postReplyComment, Use studentId = "삭제된 사용자입니다."; content = "삭제된 댓글입니다."; } - return new PostReplyCommentResponse( - postReplyComment.getId(), - user.getName(), - studentId, - content, - postReplyComment.getCreatedAt(), - postReplyComment.getLastEditedAt(), - likeCount, - isAuthor, - isLiked, - postReplyComment.getIsDeleted() - ); + return PostReplyCommentResponse.builder() + .id(postReplyComment.getId()) + .authorName(user.getName()) + .studentId(studentId) + .content(content) + .createdAt(postReplyComment.getCreatedAt()) + .lastEditedAt(postReplyComment.getLastEditedAt()) + .likeCount(likeCount) + .isAuthor(isAuthor) + .isLiked(isLiked) + .isDeleted(postReplyComment.getIsDeleted()) + .build(); + } + + public void canAuthority(List canAuthorityList) { + this.canAuthority = canAuthorityList; } }