feat: qna 조회 수정
This commit is contained in:
parent
c99d3cc7ec
commit
9c2abc6d6d
@ -106,9 +106,9 @@ public class QnaController {
|
||||
}
|
||||
|
||||
@GetMapping("/{id}")
|
||||
public ResponseEntity<Qna> getQna(@PathVariable Long id) {
|
||||
public ResponseEntity<QnaResponseDto> getQna(@PathVariable Long id) {
|
||||
try{
|
||||
Qna findQna= qnaService.getQna(id);
|
||||
QnaResponseDto findQna= qnaService.getQna(id);
|
||||
return new ResponseEntity<>(findQna, HttpStatus.ACCEPTED);
|
||||
|
||||
} catch (SQLException e) {
|
||||
|
@ -13,7 +13,6 @@ import java.util.List;
|
||||
@Repository
|
||||
public interface QnaRepository extends JpaRepository<Qna, Long> {
|
||||
|
||||
|
||||
List<Qna> findByLectureId(Long lecturerId);
|
||||
Page<Qna> findByLectureId(Long lectureId, Pageable pageable);
|
||||
}
|
||||
|
@ -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<QnaResponseDto> getAllQnasByLecture(Long lectureId,int pageNumber) throws SQLException;
|
||||
QnaResponseDto createAnswer(Long id,QnaRequestDto qnaRequestDto) throws SQLException;
|
||||
|
@ -80,8 +80,22 @@ qnaRepository.deleteById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Qna getQna(Long id) {
|
||||
return null;
|
||||
public QnaResponseDto getQna(Long id) {
|
||||
Optional<Qna> qna;
|
||||
try {
|
||||
|
||||
qna= qnaRepository.findById(id);
|
||||
|
||||
|
||||
} catch (Exception e) {
|
||||
|
||||
throw new RuntimeException("Qna 없음 " + id, e);
|
||||
}
|
||||
|
||||
|
||||
|
||||
return QnaResponseDto.toEntity(qna.get());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user