Skip to content

Commit

Permalink
feat: 카공 질문 답변 목록 조회 api 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
donghyun0304 committed Mar 31, 2024
1 parent a24fd05 commit fad5a54
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
12 changes: 12 additions & 0 deletions src/main/java/com/example/demo/controller/StudyOnceController.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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<StudyOnceSearchResponse> search(@PathVariable Long studyOnceId) {
Expand Down Expand Up @@ -184,4 +187,13 @@ public ResponseEntity<StudyOnceCommentResponse> deleteReply(@PathVariable final
studyOnceCommentService.deleteReply(commentId);
return ResponseEntity.ok(response);
}

@GetMapping("/{studyOnceId:[0-9]+}/comment/list")
public ResponseEntity<StudyOnceCommentsSearchResponse> searchComments(@PathVariable Long studyOnceId,
@RequestHeader("Authorization") String authorization) {
cafegoryTokenManager.getIdentityId(authorization);
StudyOnceCommentsSearchResponse response = studyOnceCommentQueryService.searchSortedCommentsByStudyOnceId(
studyOnceId);
return ResponseEntity.ok(response);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,4 @@ public interface StudyOnceCommentRepository extends JpaRepository<StudyOnceComme
+ " where c.studyOnce.id = :studyOnceId"
+ " order by c.id asc")
List<StudyOnceComment> findAllByStudyOnceId(@Param("studyOnceId") Long studyOnceId);

}
Original file line number Diff line number Diff line change
Expand Up @@ -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");

}

}

0 comments on commit fad5a54

Please sign in to comment.