-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
[REFACTOR] 커뮤니티 코드 리팩터링
- Loading branch information
Showing
26 changed files
with
661 additions
and
806 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
69 changes: 0 additions & 69 deletions
69
src/main/java/meltingpot/server/comment/converter/CommentConverter.java
This file was deleted.
Oops, something went wrong.
28 changes: 0 additions & 28 deletions
28
src/main/java/meltingpot/server/comment/converter/CommentImageConverter.java
This file was deleted.
Oops, something went wrong.
27 changes: 27 additions & 0 deletions
27
src/main/java/meltingpot/server/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,27 @@ | ||
package meltingpot.server.comment.dto; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import meltingpot.server.domain.entity.Account; | ||
import meltingpot.server.domain.entity.comment.Comment; | ||
import meltingpot.server.domain.entity.post.Post; | ||
|
||
@Getter | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class CommentCreateRequest { | ||
private String content; | ||
private Boolean isAnonymous; | ||
private String imageKey; | ||
|
||
public Comment toEntity(Post post, Account account, Comment parentComment){ | ||
return Comment.builder() | ||
.content(content) | ||
.isAnonymous(isAnonymous) | ||
.post(post) | ||
.account(account) | ||
.parent(parentComment) | ||
.build(); | ||
} | ||
} |
27 changes: 0 additions & 27 deletions
27
src/main/java/meltingpot/server/comment/dto/CommentRequestDTO.java
This file was deleted.
Oops, something went wrong.
51 changes: 0 additions & 51 deletions
51
src/main/java/meltingpot/server/comment/dto/CommentResponseDTO.java
This file was deleted.
Oops, something went wrong.
57 changes: 57 additions & 0 deletions
57
src/main/java/meltingpot/server/comment/dto/CommentsListResponse.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,57 @@ | ||
package meltingpot.server.comment.dto; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import meltingpot.server.domain.entity.comment.Comment; | ||
|
||
import java.time.LocalDateTime; | ||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
@Builder | ||
public class CommentsListResponse { | ||
private List<CommentDetail> commentsList; | ||
private Long nextCursor; | ||
private Boolean isLast; | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
@Builder | ||
public static class CommentDetail { | ||
private Long commentId; | ||
private Long parentId; | ||
private Long userId; | ||
private String content; | ||
private String name; | ||
private Boolean isAnonymous; | ||
private String imageUrl; | ||
private LocalDateTime updatedAt; | ||
|
||
public static CommentDetail from(Comment comment) { | ||
return CommentDetail.builder() | ||
.commentId(comment.getId()) | ||
.parentId(comment.getParent() != null ? comment.getParent().getId() : null) | ||
.userId(comment.getAccount().getId()) | ||
.content(comment.getContent()) | ||
.name(comment.getAccount().getName()) | ||
.isAnonymous(comment.getIsAnonymous()) | ||
.imageUrl(comment.getCommentImage() != null ? comment.getCommentImage().getImageUrl() : null) | ||
.updatedAt(comment.getUpdatedAt()) | ||
.build(); | ||
} | ||
} | ||
|
||
public static CommentsListResponse from(List<CommentDetail> commentDetails, Long nextCursor, Boolean isLast) { | ||
return CommentsListResponse.builder() | ||
.commentsList(commentDetails) | ||
.nextCursor(nextCursor) | ||
.isLast(isLast) | ||
.build(); | ||
} | ||
} |
Oops, something went wrong.