From 3ce5466c4948f14ce1a0ecee82a4106769930702 Mon Sep 17 00:00:00 2001 From: OZIIJIN Date: Sun, 24 Nov 2024 02:07:58 +0900 Subject: [PATCH] =?UTF-8?q?refactor=20:=20responseDto=20imageIndex=20?= =?UTF-8?q?=EC=A0=84=EC=86=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../example/demo/domain/dto/answer/AnswerResponseDto.java | 5 ++++- .../demo/domain/dto/question/QuestionResponseDTO.java | 4 +++- .../com/example/demo/domain/entity/question/Question.java | 3 +++ .../java/com/example/demo/service/answer/AnswerService.java | 2 +- .../com/example/demo/service/question/QuestionService.java | 1 + 5 files changed, 12 insertions(+), 3 deletions(-) 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(); } }