-
Notifications
You must be signed in to change notification settings - Fork 2
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
4 changed files
with
70 additions
and
74 deletions.
There are no files selected for viewing
15 changes: 15 additions & 0 deletions
15
src/main/java/com/api/TaveShot/domain/Comment/dto/CommentCreateRequest.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,15 @@ | ||
package com.api.TaveShot.domain.Comment.dto; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
@Builder | ||
public class CommentCreateRequest { | ||
private final String comment; | ||
private final String memberId; | ||
private final Long postId; | ||
private final Long parentCommentId; | ||
} |
74 changes: 0 additions & 74 deletions
74
src/main/java/com/api/TaveShot/domain/Comment/dto/CommentDto.java
This file was deleted.
Oops, something went wrong.
43 changes: 43 additions & 0 deletions
43
src/main/java/com/api/TaveShot/domain/Comment/dto/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,43 @@ | ||
package com.api.TaveShot.domain.Comment.dto; | ||
|
||
import com.api.TaveShot.domain.Comment.domain.Comment; | ||
import com.querydsl.core.annotations.QueryProjection; | ||
import lombok.Getter; | ||
|
||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
@Getter | ||
public class CommentResponse { | ||
private final Long id; | ||
private final String comment; | ||
private final String memberId; | ||
private final Long postId; | ||
private final CommentResponse parentComment; | ||
private final List<CommentResponse> replies; | ||
|
||
@QueryProjection | ||
public CommentResponse(Long id, String comment, String memberId, Long postId, CommentResponse parentComment, List<CommentResponse> replies) { | ||
this.id = id; | ||
this.comment = comment; | ||
this.memberId = memberId; | ||
this.postId = postId; | ||
this.parentComment = parentComment; | ||
this.replies = replies; | ||
} | ||
|
||
public static CommentResponse fromEntity(Comment commentEntity) { | ||
List<CommentResponse> replies = commentEntity.getChildComments().stream() | ||
.map(CommentResponse::fromEntity) | ||
.collect(Collectors.toList()); | ||
|
||
return new CommentResponse( | ||
commentEntity.getId(), | ||
commentEntity.getComment(), | ||
commentEntity.getMember().getGitName(), | ||
commentEntity.getPost().getId(), | ||
commentEntity.getParentComment() != null ? fromEntity(commentEntity.getParentComment()) : null, | ||
replies | ||
); | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
src/main/java/com/api/TaveShot/domain/Comment/dto/CommentUpdateRequest.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,12 @@ | ||
package com.api.TaveShot.domain.Comment.dto; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
@Builder | ||
public class CommentUpdateRequest { | ||
private final String comment; | ||
} |