Skip to content

Commit

Permalink
시험 댓글과 답글을 작성하고, 삭제할 수 있다. 더보기 버튼을 통해서 답글 목록을 조회할 수 있다. (#61)
Browse files Browse the repository at this point in the history
* refactor: heroui로 교체 및 sonner 추가

* feat: exam comment api 작성

* feat: exam comments hook

* feat: comment, reply viewer

* feat: 댓글 인풋 및 작성 기능

* feat: 댓글 더보기 버튼 추가

* feat: 버튼 호버 시 색 변경

* feat: 댓글 답글 삭제 기능 추가

* fix: vite build error 수정
  • Loading branch information
alstn113 authored Feb 28, 2025
1 parent da4d24b commit 1b7ce38
Show file tree
Hide file tree
Showing 74 changed files with 3,810 additions and 3,162 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public List<ExamRootCommentDto> findRootComments(Long examId) {
.leftJoin(replyComment).on(examComment.id.eq(replyComment.parentCommentId)
.and(replyComment.deletedAt.isNull()))
.where(examComment.examId.eq(examId).and(examComment.parentCommentId.isNull()))
.orderBy(examComment.createdAt.asc())
.orderBy(examComment.createdAt.desc())
.groupBy(
examComment.id,
examComment.content,
Expand Down Expand Up @@ -78,11 +78,11 @@ public List<ExamReplyCommentDto> findRootCommentWithReplies(Long commentId) {
replyComment.updatedAt
))
.from(examComment)
.leftJoin(member).on(examComment.memberId.eq(member.id))
.join(replyComment).on(examComment.id.eq(replyComment.parentCommentId)
.and(replyComment.deletedAt.isNull()))
.leftJoin(member).on(replyComment.memberId.eq(member.id))
.where(examComment.id.eq(commentId))
.orderBy(replyComment.createdAt.asc())
.orderBy(replyComment.createdAt.desc())
.fetch();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,12 @@ void getRootComments() {
// then
assertAll(
() -> assertThat(rootComments).hasSize(2),
() -> assertThat(rootComments.get(0).getId()).isEqualTo(root1.getId()),
() -> assertThat(rootComments.get(0).getReplyCount()).isEqualTo(1),
() -> assertThat(rootComments.get(1).getId()).isEqualTo(root2.getId()),
() -> assertThat(rootComments.get(1).getReplyCount()).isZero()

() -> assertThat(rootComments.get(0).getId()).isEqualTo(root2.getId()),
() -> assertThat(rootComments.get(0).getReplyCount()).isZero(),

() -> assertThat(rootComments.get(1).getId()).isEqualTo(root1.getId()),
() -> assertThat(rootComments.get(1).getReplyCount()).isEqualTo(1)
);
}

Expand Down Expand Up @@ -110,15 +112,15 @@ void getRootCommentsWithDeletedComment() {
assertAll(
() -> assertThat(rootComments).hasSize(2),

() -> assertThat(rootComments.get(0).getId()).isEqualTo(root1.getId()),
() -> assertThat(rootComments.get(0).getContent()).isEmpty(),
() -> assertThat(rootComments.get(0).isDeleted()).isTrue(),
() -> assertThat(rootComments.get(0).getReplyCount()).isEqualTo(1),
() -> assertThat(rootComments.get(0).getId()).isEqualTo(root3.getId()),
() -> assertThat(rootComments.get(0).getContent()).isEqualTo("댓글3"),
() -> assertThat(rootComments.get(0).isDeleted()).isFalse(),
() -> assertThat(rootComments.get(0).getReplyCount()).isZero(),

() -> assertThat(rootComments.get(1).getId()).isEqualTo(root3.getId()),
() -> assertThat(rootComments.get(1).getContent()).isEqualTo("댓글3"),
() -> assertThat(rootComments.get(1).isDeleted()).isFalse(),
() -> assertThat(rootComments.get(1).getReplyCount()).isZero()
() -> assertThat(rootComments.get(1).getId()).isEqualTo(root1.getId()),
() -> assertThat(rootComments.get(1).getContent()).isEmpty(),
() -> assertThat(rootComments.get(1).isDeleted()).isTrue(),
() -> assertThat(rootComments.get(1).getReplyCount()).isEqualTo(1)
);
}

Expand All @@ -144,8 +146,8 @@ void getReplyComments() {
// then
assertAll(
() -> assertThat(replies).hasSize(2),
() -> assertThat(replies.get(0).getId()).isEqualTo(root1reply1.getId()),
() -> assertThat(replies.get(1).getId()).isEqualTo(root1reply3.getId())
() -> assertThat(replies.get(0).getId()).isEqualTo(root1reply3.getId()),
() -> assertThat(replies.get(1).getId()).isEqualTo(root1reply1.getId())
);
}

Expand Down Expand Up @@ -235,14 +237,15 @@ void getRootCommentsAndReplyComments() {
// then
assertAll(
() -> assertThat(rootComments).hasSize(2),
() -> assertThat(rootComments.get(0).getId()).isEqualTo(root1.getId()),
() -> assertThat(rootComments.get(0).getContent()).isEmpty(),
() -> assertThat(rootComments.get(0).isDeleted()).isTrue(),

() -> assertThat(rootComments.get(0).getId()).isEqualTo(root2.getId()),
() -> assertThat(rootComments.get(0).getContent()).isEqualTo("댓글2"),
() -> assertThat(rootComments.get(0).isDeleted()).isFalse(),
() -> assertThat(rootComments.get(0).getReplyCount()).isEqualTo(1),

() -> assertThat(rootComments.get(1).getId()).isEqualTo(root2.getId()),
() -> assertThat(rootComments.get(1).getContent()).isEqualTo("댓글2"),
() -> assertThat(rootComments.get(1).isDeleted()).isFalse(),
() -> assertThat(rootComments.get(1).getId()).isEqualTo(root1.getId()),
() -> assertThat(rootComments.get(1).getContent()).isEmpty(),
() -> assertThat(rootComments.get(1).isDeleted()).isTrue(),
() -> assertThat(rootComments.get(1).getReplyCount()).isEqualTo(1),

() -> assertThat(root1replies).hasSize(1),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,20 +61,20 @@ void findRootComments() {
assertAll(
() -> assertThat(rootComments).hasSize(3),

() -> assertThat(rootComments.get(0).getId()).isEqualTo(root1.getId()),
() -> assertThat(rootComments.get(0).getContent()).isEqualTo("댓글1"),
() -> assertThat(rootComments.get(0).getAuthor().getName()).isEqualTo(member1.getName()),
() -> assertThat(rootComments.get(0).getReplyCount()).isEqualTo(2),
() -> assertThat(rootComments.get(0).getId()).isEqualTo(root3.getId()),
() -> assertThat(rootComments.get(0).getContent()).isEqualTo("댓글3"),
() -> assertThat(rootComments.get(0).getAuthor().getName()).isEqualTo(member2.getName()),
() -> assertThat(rootComments.get(0).getReplyCount()).isEqualTo(1),

() -> assertThat(rootComments.get(1).getId()).isEqualTo(root2.getId()),
() -> assertThat(rootComments.get(1).getContent()).isEqualTo("댓글2"),
() -> assertThat(rootComments.get(1).getAuthor().getName()).isEqualTo(member2.getName()),
() -> assertThat(rootComments.get(1).getReplyCount()).isZero(),

() -> assertThat(rootComments.get(2).getId()).isEqualTo(root3.getId()),
() -> assertThat(rootComments.get(2).getContent()).isEqualTo("댓글3"),
() -> assertThat(rootComments.get(2).getAuthor().getName()).isEqualTo(member2.getName()),
() -> assertThat(rootComments.get(2).getReplyCount()).isEqualTo(1)
() -> assertThat(rootComments.get(2).getId()).isEqualTo(root1.getId()),
() -> assertThat(rootComments.get(2).getContent()).isEqualTo("댓글1"),
() -> assertThat(rootComments.get(2).getAuthor().getName()).isEqualTo(member1.getName()),
() -> assertThat(rootComments.get(2).getReplyCount()).isEqualTo(2)
);
}

Expand Down Expand Up @@ -118,13 +118,14 @@ void findRootCommentsWithDeletedComment() {
assertAll(
() -> assertThat(rootComments).hasSize(2),

() -> assertThat(rootComments.get(0).getId()).isEqualTo(root2.getId()),
() -> assertThat(rootComments.get(0).isDeleted()).isTrue(),
() -> assertThat(rootComments.get(0).getReplyCount()).isEqualTo(1),

() -> assertThat(rootComments.get(1).getId()).isEqualTo(root3.getId()),
() -> assertThat(rootComments.get(1).isDeleted()).isFalse(),
() -> assertThat(rootComments.get(1).getReplyCount()).isZero()
() -> assertThat(rootComments.get(0).getId()).isEqualTo(root3.getId()),
() -> assertThat(rootComments.get(0).isDeleted()).isFalse(),
() -> assertThat(rootComments.get(0).getReplyCount()).isZero(),

() -> assertThat(rootComments.get(1).getId()).isEqualTo(root2.getId()),
() -> assertThat(rootComments.get(1).isDeleted()).isTrue(),
() -> assertThat(rootComments.get(1).getReplyCount()).isEqualTo(1)
);
}

Expand Down Expand Up @@ -154,10 +155,10 @@ void findRootCommentWithReplies() {
assertAll(
() -> assertThat(replies).hasSize(2),

() -> assertThat(replies.get(0).getContent()).isEqualTo("댓글1-답글1"),
() -> assertThat(replies.get(0).getContent()).isEqualTo("댓글1-답글2"),
() -> assertThat(replies.get(0).getAuthor().getName()).isEqualTo(member1.getName()),

() -> assertThat(replies.get(1).getContent()).isEqualTo("댓글1-답글2"),
() -> assertThat(replies.get(1).getContent()).isEqualTo("댓글1-답글1"),
() -> assertThat(replies.get(1).getAuthor().getName()).isEqualTo(member1.getName())
);
}
Expand Down
2 changes: 1 addition & 1 deletion web/.npmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
public-hoist-pattern[]=*@nextui-org/*
public-hoist-pattern[]=*@heroui/*
7 changes: 3 additions & 4 deletions web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@
"preview": "vite preview"
},
"dependencies": {
"@daveyplate/nextui-fixed-avatar": "^1.0.4",
"@hello-pangea/dnd": "^17.0.0",
"@nextui-org/react": "^2.4.8",
"@heroui/react": "^2.7.2",
"@tanstack/react-query": "^5.59.16",
"@uiw/react-md-editor": "^4.0.5",
"axios": "^1.7.7",
Expand All @@ -23,10 +22,10 @@
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-error-boundary": "^4.1.2",
"react-hot-toast": "^2.4.1",
"react-icons": "^5.4.0",
"react-router": "^7.0.2",
"rehype-sanitize": "^6.0.0",
"sonner": "^2.0.1",
"zustand": "^5.0.0"
},
"devDependencies": {
Expand All @@ -46,7 +45,7 @@
"tailwindcss": "^3.4.15",
"typescript": "~5.6.2",
"typescript-eslint": "^8.10.0",
"vite": "^5.4.9",
"vite": "^5.4.14",
"vite-tsconfig-paths": "^5.1.0"
},
"packageManager": "[email protected]"
Expand Down
Loading

0 comments on commit 1b7ce38

Please sign in to comment.