package online.wesal.wesal.dto;

import online.wesal.wesal.entity.Comment;
import online.wesal.wesal.entity.User;
import java.time.LocalDateTime;
import java.util.List;
import java.util.ArrayList;

public class CommentResponseDTO {
    
    private String id;
    private String postId;
    private CreatorDTO creator;
    private String body;
    private LocalDateTime creationDate;
    private String replyComment;
    private String displayReplyComment;
    private CreatorDTO replyUser;
    private Integer level;
    private List<CommentResponseDTO> replies;
    
    public CommentResponseDTO() {}
    
    public CommentResponseDTO(Comment comment, User creator, User replyUser) {
        this.id = String.valueOf(comment.getId());
        this.postId = String.valueOf(comment.getPostId());
        this.creator = new CreatorDTO(creator);
        this.body = comment.getBody();
        this.creationDate = comment.getCreationDate();
        this.replyComment = comment.getReplyComment() != null ? String.valueOf(comment.getReplyComment()) : null;
        this.displayReplyComment = comment.getDisplayReplyComment() != null ? String.valueOf(comment.getDisplayReplyComment()) : null;
        this.replyUser = replyUser != null ? new CreatorDTO(replyUser) : null;
        this.level = comment.getLevel();
        this.replies = new ArrayList<>();
    }
    
    public String getId() {
        return id;
    }
    
    public void setId(String id) {
        this.id = id;
    }
    
    public String getPostId() {
        return postId;
    }
    
    public void setPostId(String postId) {
        this.postId = postId;
    }
    
    public CreatorDTO getCreator() {
        return creator;
    }
    
    public void setCreator(CreatorDTO creator) {
        this.creator = creator;
    }
    
    public String getBody() {
        return body;
    }
    
    public void setBody(String body) {
        this.body = body;
    }
    
    public LocalDateTime getCreationDate() {
        return creationDate;
    }
    
    public void setCreationDate(LocalDateTime creationDate) {
        this.creationDate = creationDate;
    }
    
    public String getReplyComment() {
        return replyComment;
    }
    
    public void setReplyComment(String replyComment) {
        this.replyComment = replyComment;
    }
    
    public String getDisplayReplyComment() {
        return displayReplyComment;
    }
    
    public void setDisplayReplyComment(String displayReplyComment) {
        this.displayReplyComment = displayReplyComment;
    }
    
    public CreatorDTO getReplyUser() {
        return replyUser;
    }
    
    public void setReplyUser(CreatorDTO replyUser) {
        this.replyUser = replyUser;
    }
    
    public Integer getLevel() {
        return level;
    }
    
    public void setLevel(Integer level) {
        this.level = level;
    }
    
    public List<CommentResponseDTO> getReplies() {
        return replies;
    }
    
    public void setReplies(List<CommentResponseDTO> replies) {
        this.replies = replies;
    }
}