diff --git a/src/main/java/com/example/demo/domain/dto/answer/AnswerResponseDto.java b/src/main/java/com/example/demo/domain/dto/answer/AnswerResponseDto.java index 71df26d..55950e1 100644 --- a/src/main/java/com/example/demo/domain/dto/answer/AnswerResponseDto.java +++ b/src/main/java/com/example/demo/domain/dto/answer/AnswerResponseDto.java @@ -5,11 +5,14 @@ @Getter public class AnswerResponseDto { + private int imageIndex; + private String question; private String answer; - public AnswerResponseDto(String question, String answer) { + public AnswerResponseDto(int imageIndex, String question, String answer) { + this.imageIndex = imageIndex; this.question = question; this.answer = answer; } diff --git a/src/main/java/com/example/demo/domain/dto/question/QuestionResponseDTO.java b/src/main/java/com/example/demo/domain/dto/question/QuestionResponseDTO.java index d566d21..b8e992f 100644 --- a/src/main/java/com/example/demo/domain/dto/question/QuestionResponseDTO.java +++ b/src/main/java/com/example/demo/domain/dto/question/QuestionResponseDTO.java @@ -11,8 +11,10 @@ public class QuestionResponseDTO { private Long questionId; private String question; - public QuestionResponseDTO(Long questionId, String question) { + private int imageIndex; + public QuestionResponseDTO(Long questionId, String question, int imageIndex) { this.questionId = questionId; this.question = question; + this.imageIndex = imageIndex; } } diff --git a/src/main/java/com/example/demo/domain/entity/question/Question.java b/src/main/java/com/example/demo/domain/entity/question/Question.java index 12bd84a..a470403 100644 --- a/src/main/java/com/example/demo/domain/entity/question/Question.java +++ b/src/main/java/com/example/demo/domain/entity/question/Question.java @@ -26,6 +26,9 @@ public class Question extends BaseEntity { @Column(nullable = false, columnDefinition = "VARCHAR(15)") private QuestionCategory questionCategory; + @Column + private int imageIndex; + public Question(String question) { this.question = question; } diff --git a/src/main/java/com/example/demo/service/answer/AnswerService.java b/src/main/java/com/example/demo/service/answer/AnswerService.java index 3920a7c..8a99e7c 100644 --- a/src/main/java/com/example/demo/service/answer/AnswerService.java +++ b/src/main/java/com/example/demo/service/answer/AnswerService.java @@ -49,7 +49,7 @@ public AnswerCreateResponseDto createAnswer(AnswerRequestDto dto) { public AnswerResponseDto getAnswer(String uuid) { QuestionAnswer questionAnswer = questionAnswerQuery.findByUUID(uuid); - return new AnswerResponseDto(questionAnswer.getQuestion().getQuestion(), + return new AnswerResponseDto(questionAnswer.getQuestion().getImageIndex(),questionAnswer.getQuestion().getQuestion(), questionAnswer.getAnswer().getAnswer()); } } diff --git a/src/main/java/com/example/demo/service/question/QuestionService.java b/src/main/java/com/example/demo/service/question/QuestionService.java index 1c68892..9e9d9d0 100644 --- a/src/main/java/com/example/demo/service/question/QuestionService.java +++ b/src/main/java/com/example/demo/service/question/QuestionService.java @@ -44,6 +44,7 @@ public QuestionResponseDTO getRandomQuestion(QuestionCategory category) { return QuestionResponseDTO.builder() .questionId(q.getId()) .question(q.getQuestion()) + .imageIndex(q.getImageIndex()) .build(); } }