diff --git a/backend/src/main/java/com/edufocus/edufocus/qna/controller/QnaController.java b/backend/src/main/java/com/edufocus/edufocus/qna/controller/QnaController.java index 48cc08a..6ba7628 100644 --- a/backend/src/main/java/com/edufocus/edufocus/qna/controller/QnaController.java +++ b/backend/src/main/java/com/edufocus/edufocus/qna/controller/QnaController.java @@ -106,9 +106,9 @@ public class QnaController { } @GetMapping("/{id}") - public ResponseEntity getQna(@PathVariable Long id) { + public ResponseEntity getQna(@PathVariable Long id) { try{ - Qna findQna= qnaService.getQna(id); + QnaResponseDto findQna= qnaService.getQna(id); return new ResponseEntity<>(findQna, HttpStatus.ACCEPTED); } catch (SQLException e) { diff --git a/backend/src/main/java/com/edufocus/edufocus/qna/repository/QnaRepository.java b/backend/src/main/java/com/edufocus/edufocus/qna/repository/QnaRepository.java index d2cbf7f..9d1c71e 100644 --- a/backend/src/main/java/com/edufocus/edufocus/qna/repository/QnaRepository.java +++ b/backend/src/main/java/com/edufocus/edufocus/qna/repository/QnaRepository.java @@ -13,7 +13,6 @@ import java.util.List; @Repository public interface QnaRepository extends JpaRepository { - List findByLectureId(Long lecturerId); Page findByLectureId(Long lectureId, Pageable pageable); } diff --git a/backend/src/main/java/com/edufocus/edufocus/qna/service/QnaService.java b/backend/src/main/java/com/edufocus/edufocus/qna/service/QnaService.java index 2c84b6d..de97f93 100644 --- a/backend/src/main/java/com/edufocus/edufocus/qna/service/QnaService.java +++ b/backend/src/main/java/com/edufocus/edufocus/qna/service/QnaService.java @@ -16,7 +16,7 @@ public interface QnaService { QnaResponseDto createQna(Long id, QnaRequestDto qnaRequestDto, Long lecture_id) throws SQLException; QnaResponseDto updateQna(Long id,QnaRequestDto qnaRequestDto) throws SQLException; void deleteQna(Long id) throws SQLException; - Qna getQna(Long id) throws SQLException; + QnaResponseDto getQna(Long id) throws SQLException; List getAllQnasByLecture(Long lectureId,int pageNumber) throws SQLException; QnaResponseDto createAnswer(Long id,QnaRequestDto qnaRequestDto) throws SQLException; diff --git a/backend/src/main/java/com/edufocus/edufocus/qna/service/QnaServiceImpl.java b/backend/src/main/java/com/edufocus/edufocus/qna/service/QnaServiceImpl.java index e53f585..bed4103 100644 --- a/backend/src/main/java/com/edufocus/edufocus/qna/service/QnaServiceImpl.java +++ b/backend/src/main/java/com/edufocus/edufocus/qna/service/QnaServiceImpl.java @@ -80,8 +80,22 @@ qnaRepository.deleteById(id); } @Override - public Qna getQna(Long id) { - return null; + public QnaResponseDto getQna(Long id) { + Optional qna; + try { + + qna= qnaRepository.findById(id); + + + } catch (Exception e) { + + throw new RuntimeException("Qna 없음 " + id, e); + } + + + + return QnaResponseDto.toEntity(qna.get()); + } @Override