-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
99 additions
and
0 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
backend/src/main/java/com/votogether/domain/post/dto/response/CommentResponse.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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package com.votogether.domain.post.dto.response; | ||
|
||
import com.votogether.domain.member.entity.Member; | ||
import com.votogether.domain.post.entity.comment.Comment; | ||
import java.time.LocalDateTime; | ||
|
||
public record CommentResponse( | ||
Long id, | ||
CommentMember member, | ||
String content, | ||
LocalDateTime createdAt, | ||
LocalDateTime updatedAt | ||
) { | ||
|
||
public static CommentResponse from(final Comment comment) { | ||
return new CommentResponse( | ||
comment.getId(), | ||
CommentMember.from(comment.getMember()), | ||
comment.getContent(), | ||
comment.getCreatedAt(), | ||
comment.getUpdatedAt() | ||
); | ||
} | ||
|
||
record CommentMember(Long id, String nickname) { | ||
|
||
public static CommentMember from(final Member member) { | ||
return new CommentMember(member.getId(), member.getNickname()); | ||
} | ||
|
||
} | ||
|
||
} |
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