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