-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[refactor] canAuthority 대댓글 반환 값에도 포함
- Loading branch information
1 parent
90e200d
commit b3bc923
Showing
3 changed files
with
54 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 47 additions & 24 deletions
71
...ava/ussum/homepage/application/comment/service/dto/response/PostReplyCommentResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,61 @@ | ||
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<String> 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<String> 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(); | ||
if (postReplyComment.getIsDeleted().equals(true)) { | ||
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<String> canAuthorityList) { | ||
this.canAuthority = canAuthorityList; | ||
} | ||
} |