BaseQuestionDTO.java 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. package nju.seec.helper.dto.question;
  2. import com.fasterxml.jackson.annotation.JsonSubTypes;
  3. import com.fasterxml.jackson.annotation.JsonTypeInfo;
  4. import lombok.Data;
  5. import nju.seec.helper.dto.groups.Create;
  6. import org.hibernate.validator.constraints.Length;
  7. import javax.validation.constraints.NotBlank;
  8. import javax.validation.constraints.NotNull;
  9. import java.util.List;
  10. /**
  11. * @author cst
  12. */
  13. @Data
  14. @JsonTypeInfo(
  15. use = JsonTypeInfo.Id.NAME,
  16. include = JsonTypeInfo.As.EXISTING_PROPERTY,
  17. property = "type",
  18. visible = true
  19. )
  20. @JsonSubTypes({
  21. @JsonSubTypes.Type(value = ChoiceQuestionDTO.class, name = BaseQuestionDTO.CHOICE),
  22. @JsonSubTypes.Type(value = TrueOrFalseQuestionDTO.class, name = BaseQuestionDTO.TRUE_FALSE)
  23. })
  24. public abstract class BaseQuestionDTO {
  25. protected static final String CHOICE = "choice";
  26. protected static final String TRUE_FALSE = "true_false";
  27. @NotBlank(message = "题干不能为空")
  28. @Length(max = 1000, message = "题干长度不能超过1000")
  29. protected String stem;
  30. @Length(max = 1000, message = "解析长度不能超过1000")
  31. protected String analysis;
  32. @NotNull(message = "缺少题目类型", groups = Create.class)
  33. protected String type;
  34. protected String keyPoints;
  35. protected List<String> tags;
  36. protected List<String> knowledgeId;
  37. }