Skip to content
Merged

fix #111

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ public class CommentReplyRequestDto {

private int commentId; // 대댓글이 달릴 원본 댓글 ID
private String commentReplyContent; // 대댓글 내용
private String commentReplyNickname; // 대댓글 작성자 닉네임
private String userId;
private LocalDateTime commentReplyDate; // 대댓글 작성 날짜
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ public class CommentRequestDto {

private String contentId; // 댓글 달릴 게시글 ID
private String commentContent; // 댓글 내용
private String commentNickname; // 댓글 작성자 닉네임
private String userId; // 댓글 작성자 닉네임
private LocalDateTime commentDate; // 댓글 작성 날짜
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@

import com.example.prdoit.dto.comment.*;
import com.example.prdoit.exception.CustomException;
import com.example.prdoit.model.CommentCommentTable;
import com.example.prdoit.model.CommentTable;
import com.example.prdoit.model.ContentTable;
import com.example.prdoit.model.NotificationTable;
import com.example.prdoit.model.*;
import com.example.prdoit.repository.*;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
Expand Down Expand Up @@ -61,9 +58,11 @@ public void postComment(CommentRequestDto commentRequestDto) {
ContentTable contentTable = contentTableRepository.findById(commentRequestDto.getContentId())
.orElseThrow(() -> new CustomException("해당 게시글이 없습니다."));

IdTable idTable = idTableRepository.findById(commentRequestDto.getUserId()).orElseThrow(()-> new CustomException("해당 아이디가 존재하지 않습니다."));

commentTableRepository.save(CommentTable.builder()
.commentContent(commentRequestDto.getCommentContent())
.commentNickname(commentRequestDto.getCommentNickname())
.commentNickname(idTable.getNickname())
.commentDate(commentRequestDto.getCommentDate())
.contentId(contentTable)
.build());
Expand All @@ -87,9 +86,11 @@ public void postCommentReply(CommentReplyRequestDto commentReplyRequestDto) {
CommentTable parentComment = commentTableRepository.findById(commentReplyRequestDto.getCommentId())
.orElseThrow(() -> new CustomException("해당 댓글이 없습니다."));

IdTable idTable = idTableRepository.findById(commentReplyRequestDto.getUserId()).orElseThrow(()->new CustomException("해당아이디가 존재하지 않습니다."));

commentCommentTableRepository.save(CommentCommentTable.builder()
.commentCommentContent(commentReplyRequestDto.getCommentReplyContent())
.userNickname(commentReplyRequestDto.getCommentReplyNickname())
.userNickname(idTable.getNickname())
.commentCommentDate(commentReplyRequestDto.getCommentReplyDate())
.commentId(parentComment)
.build());
Expand Down