Skip to content

Commit

Permalink
refactor : 답변 조회 Path Variable 검증 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
hcg0127 committed Nov 23, 2024
1 parent cdeca90 commit 8c261a9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ public enum ErrorStatus implements BaseErrorCode {
QUESTION_NOT_FOUND(HttpStatus.NOT_FOUND, "QUESTION4005", "해당 질문을 찾을 수 없습니다."),

// 답변 관련 에러
ANSWER_NOT_FOUND(HttpStatus.NOT_FOUND, "ANSWER4004", "해당 답변을 찾을 수 없습니다.");
ANSWER_NOT_FOUND(HttpStatus.NOT_FOUND, "ANSWER4004", "해당 답변을 찾을 수 없습니다."),

// 답변 & 질문 에러
QUESTION_ANSWER_NOT_FOUND(HttpStatus.NOT_FOUND, "QUESTION_ANSWER4001", "해당 질문과 답변을 찾을 수 없습니다.");


private final HttpStatus httpStatus;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ public AnswerCreateResponseDto createAnswer(AnswerRequestDto dto) {
@Transactional(readOnly = true)
public AnswerResponseDto getAnswer(String uuid) {
QuestionAnswer questionAnswer = questionAnswerQuery.findByUUID(uuid);
if (questionAnswer == null) {
throw new GeneralException(ErrorStatus.QUESTION_ANSWER_NOT_FOUND.getReasonHttpStatus());
}

return new AnswerResponseDto(questionAnswer.getQuestion().getQuestion(),
questionAnswer.getAnswer().getAnswer());
Expand Down

0 comments on commit 8c261a9

Please sign in to comment.