42 lines
1.4 KiB
Java
42 lines
1.4 KiB
Java
package sgis.surveysystem.dto;
|
|
|
|
import java.util.List;
|
|
import java.util.UUID;
|
|
|
|
import lombok.AllArgsConstructor;
|
|
import lombok.Builder;
|
|
import lombok.Getter;
|
|
import lombok.NoArgsConstructor;
|
|
import lombok.Setter;
|
|
import sgis.surveysystem.domain.Question;
|
|
|
|
//문항 응답 DTO (선택지 포함 가능)
|
|
@Getter
|
|
@Setter // Setter가 필요한 경우 (예: Controller에서 옵션 리스트를 동적으로 설정)
|
|
@Builder
|
|
@NoArgsConstructor
|
|
@AllArgsConstructor
|
|
public class QuestionResponse {
|
|
private UUID questionId;
|
|
private UUID surveyId; // 어떤 설문에 속하는지
|
|
private String questionText;
|
|
private String questionType;
|
|
private Integer questionOrder;
|
|
private Boolean isRequired;
|
|
private List<QuestionOptionResponse> options; // 객관식 문항의 선택지 리스트 (서비스/컨트롤러에서 채움)
|
|
|
|
public static QuestionResponse from(Question question) {
|
|
if (question == null) {
|
|
return null;
|
|
}
|
|
return QuestionResponse.builder()
|
|
.questionId(question.getQuestionId())
|
|
.surveyId(question.getSurveyId())
|
|
.questionText(question.getQuestionText())
|
|
.questionType(question.getQuestionType())
|
|
.questionOrder(question.getQuestionOrder())
|
|
.isRequired(question.getIsRequired())
|
|
// options 필드는 기본적으로 null로 두고, Controller/Service에서 필요한 경우 채웁니다.
|
|
.build();
|
|
}
|
|
} |