package nju.seec.helper.dto.question; import com.fasterxml.jackson.annotation.JsonSubTypes; import com.fasterxml.jackson.annotation.JsonTypeInfo; import lombok.Data; import nju.seec.helper.dto.groups.Create; import org.hibernate.validator.constraints.Length; import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotNull; import java.util.List; /** * @author cst */ @Data @JsonTypeInfo( use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.EXISTING_PROPERTY, property = "type", visible = true ) @JsonSubTypes({ @JsonSubTypes.Type(value = ChoiceQuestionDTO.class, name = BaseQuestionDTO.CHOICE), @JsonSubTypes.Type(value = TrueOrFalseQuestionDTO.class, name = BaseQuestionDTO.TRUE_FALSE) }) public abstract class BaseQuestionDTO { protected static final String CHOICE = "choice"; protected static final String TRUE_FALSE = "true_false"; @NotBlank(message = "题干不能为空") @Length(max = 1000, message = "题干长度不能超过1000") protected String stem; @Length(max = 1000, message = "解析长度不能超过1000") protected String analysis; @NotNull(message = "缺少题目类型", groups = Create.class) protected String type; protected String keyPoints; protected List tags; protected List knowledgeId; }