Skip to content

Commit

Permalink
Merge pull request #93 from Developer-Wikis/feature/#88
Browse files Browse the repository at this point in the history
Feature/#88
  • Loading branch information
dhkstnaos authored Nov 17, 2022
2 parents 5db4c11 + 52e82b5 commit 2ea1481
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import java.time.LocalDateTime;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
Expand Down Expand Up @@ -33,8 +35,9 @@ public class Comment {
@Column(name = "content")
private String content;

@Column(name = "status")
private CommentStatus commentStatus;
@Column(name = "role")
@Enumerated(EnumType.STRING)
private CommentRole commentRole;

@Column(name = "created_at")
private LocalDateTime createdAt;
Expand All @@ -49,7 +52,7 @@ public Comment(String nickname, String password, String content, Question questi
this.nickname = nickname;
this.password = password;
this.content = content;
this.commentStatus = CommentStatus.ANONYMOUS;
this.commentRole = CommentRole.ANONYMOUS;
this.question = question;
this.createdAt = LocalDateTime.now();
this.userId = null;
Expand All @@ -59,7 +62,7 @@ public Comment(String nickname, String password, String content, Question questi
this.nickname = nickname;
this.password = password;
this.content = content;
this.commentStatus = CommentStatus.USER;
this.commentRole = CommentRole.USER;
this.question = question;
this.createdAt = LocalDateTime.now();
this.userId = userId;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package com.developer.wiki.question.command.domain;

public enum CommentStatus {
public enum CommentRole {
ANONYMOUS, USER;
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
public class SummaryCommentResponse {

private Long id;
private String nickname;
private String username;
private String role;
private Long userId;
private String content;
@DateTimeFormat(pattern = "yyyy-MM-dd")
private LocalDateTime createdAt;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.developer.wiki.question.command.domain.Comment;
import com.developer.wiki.question.command.domain.Question;
import com.developer.wiki.question.query.application.SummaryCommentResponse;
import java.util.Objects;

public class CommentConverter {

Expand All @@ -21,7 +22,9 @@ public static Comment toCommentByUser(CreateCommentRequest createCommentRequest,
}

public static SummaryCommentResponse ofSummary(Comment comment) {
return SummaryCommentResponse.builder().id(comment.getId()).nickname(comment.getNickname())
return SummaryCommentResponse.builder().id(comment.getId()).username(comment.getNickname())
.role(comment.getCommentRole().name())
.userId(Objects.isNull(comment.getId()) ? null : comment.getId())
.content(comment.getContent()).createdAt(comment.getCreatedAt()).build();
}
}

0 comments on commit 2ea1481

Please sign in to comment.