diff --git a/src/main/java/com/example/demo/domain/Question.java b/src/main/java/com/example/demo/domain/Question.java index 31cc79727641ae82db5d6cef3828d5261de4e294..b6e967f8f722a9d473774418fef3bff3d2e9453f 100644 --- a/src/main/java/com/example/demo/domain/Question.java +++ b/src/main/java/com/example/demo/domain/Question.java @@ -5,6 +5,8 @@ import com.example.demo.enums.QuestionType; import javax.persistence.CascadeType; import javax.persistence.Column; import javax.persistence.Entity; +import javax.persistence.EnumType; +import javax.persistence.Enumerated; import javax.persistence.FetchType; import javax.persistence.GeneratedValue; import javax.persistence.Id; @@ -21,6 +23,7 @@ public class Question { @GeneratedValue private Long id; + @Enumerated(EnumType.STRING) private QuestionType questionType; private String text; private Integer points; diff --git a/src/main/java/com/example/demo/dto/QuestionDto.java b/src/main/java/com/example/demo/dto/QuestionDto.java index 03044ee1ba8893e0d499e13f25e75fa418238973..40f136f8ad85ab3ace8b15d35d01a067c727ebd0 100644 --- a/src/main/java/com/example/demo/dto/QuestionDto.java +++ b/src/main/java/com/example/demo/dto/QuestionDto.java @@ -1,6 +1,5 @@ package com.example.demo.dto; -import com.example.demo.domain.QuestionnaireLevel; import com.example.demo.enums.QuestionType; import java.io.Serializable; diff --git a/src/main/java/com/example/demo/enums/QuestionType.java b/src/main/java/com/example/demo/enums/QuestionType.java index a040769c6ef09d362a84a4e3414804a383ba9781..78adce7df84410883a71bb7a0b4e89cf6430913f 100644 --- a/src/main/java/com/example/demo/enums/QuestionType.java +++ b/src/main/java/com/example/demo/enums/QuestionType.java @@ -1,4 +1,7 @@ package com.example.demo.enums; public enum QuestionType { + FFQ, + MCQ, + EMI } diff --git a/src/main/java/com/example/demo/service/QuestionService.java b/src/main/java/com/example/demo/service/QuestionService.java index faed7120a722fa404d6eb792647b56603d4d0600..443a8caeea1ae5f595bec163e18d9434f849c448 100644 --- a/src/main/java/com/example/demo/service/QuestionService.java +++ b/src/main/java/com/example/demo/service/QuestionService.java @@ -1,11 +1,9 @@ package com.example.demo.service; -import com.example.demo.domain.PhaseLevel; import com.example.demo.domain.Question; import com.example.demo.domain.QuestionnaireLevel; -import com.example.demo.domain.Task; import com.example.demo.dto.QuestionDto; -import com.example.demo.dto.TaskDto; +import com.example.demo.enums.QuestionType; import com.example.demo.mapper.BeanMapper; import com.example.demo.repository.QuestionRepository; import com.example.demo.repository.QuestionnaireLevelRepository; @@ -32,6 +30,7 @@ public class QuestionService { Question question = new Question(); question.setText("Title of question"); + question.setQuestionType(QuestionType.MCQ); question.setQuestionnaireLevel(questionnaireLevel.get()); question.setOrder(questionRepository.getCurrentMaxOrder(questionnaireId) + 1);