diff --git a/src/main/java/com/example/demo/controller/StudyOnceController.java b/src/main/java/com/example/demo/controller/StudyOnceController.java index bec6b8b8..8b947268 100644 --- a/src/main/java/com/example/demo/controller/StudyOnceController.java +++ b/src/main/java/com/example/demo/controller/StudyOnceController.java @@ -24,6 +24,7 @@ import com.example.demo.dto.StudyOnceCommentRequest; import com.example.demo.dto.StudyOnceCommentResponse; import com.example.demo.dto.StudyOnceCommentUpdateRequest; +import com.example.demo.dto.StudyOnceCommentsSearchResponse; import com.example.demo.dto.StudyOnceCreateRequest; import com.example.demo.dto.StudyOnceJoinResult; import com.example.demo.dto.StudyOnceSearchRequest; @@ -32,6 +33,7 @@ import com.example.demo.dto.UpdateAttendanceResponse; import com.example.demo.exception.CafegoryException; import com.example.demo.service.CafeQueryService; +import com.example.demo.service.StudyOnceCommentQueryService; import com.example.demo.service.StudyOnceCommentService; import com.example.demo.service.StudyOnceQAndAQueryService; import com.example.demo.service.StudyOnceService; @@ -47,6 +49,7 @@ public class StudyOnceController { private final CafeQueryService cafeQueryService; private final StudyOnceCommentService studyOnceCommentService; private final StudyOnceQAndAQueryService studyOnceQAndAQueryService; + private final StudyOnceCommentQueryService studyOnceCommentQueryService; @GetMapping("/{studyOnceId:[0-9]+}") public ResponseEntity search(@PathVariable Long studyOnceId) { @@ -184,4 +187,13 @@ public ResponseEntity deleteReply(@PathVariable final studyOnceCommentService.deleteReply(commentId); return ResponseEntity.ok(response); } + + @GetMapping("/{studyOnceId:[0-9]+}/comment/list") + public ResponseEntity searchComments(@PathVariable Long studyOnceId, + @RequestHeader("Authorization") String authorization) { + cafegoryTokenManager.getIdentityId(authorization); + StudyOnceCommentsSearchResponse response = studyOnceCommentQueryService.searchSortedCommentsByStudyOnceId( + studyOnceId); + return ResponseEntity.ok(response); + } } diff --git a/src/main/java/com/example/demo/repository/StudyOnceCommentRepository.java b/src/main/java/com/example/demo/repository/StudyOnceCommentRepository.java index ed06d9ea..07f3ce2d 100644 --- a/src/main/java/com/example/demo/repository/StudyOnceCommentRepository.java +++ b/src/main/java/com/example/demo/repository/StudyOnceCommentRepository.java @@ -16,5 +16,4 @@ public interface StudyOnceCommentRepository extends JpaRepository findAllByStudyOnceId(@Param("studyOnceId") Long studyOnceId); - } diff --git a/src/test/java/com/example/demo/repository/StudyOnceCommentRepositoryTest.java b/src/test/java/com/example/demo/repository/StudyOnceCommentRepositoryTest.java index e50d08f8..6be11bcd 100644 --- a/src/test/java/com/example/demo/repository/StudyOnceCommentRepositoryTest.java +++ b/src/test/java/com/example/demo/repository/StudyOnceCommentRepositoryTest.java @@ -73,7 +73,6 @@ void findAllByStudyOnceId() { assertThat(comments.get(1).getContent()).isEqualTo("댓글2"); assertThat(comments.get(2).getContent()).isEqualTo("대댓글2"); assertThat(comments.get(3).getContent()).isEqualTo("대댓글1"); - } }