Classification.java 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. package cn.minbb.evaluation.entity;
  2. import lombok.Getter;
  3. import lombok.NoArgsConstructor;
  4. import lombok.Setter;
  5. import org.hibernate.annotations.CreationTimestamp;
  6. import org.hibernate.annotations.UpdateTimestamp;
  7. import javax.persistence.*;
  8. import javax.persistence.Version;
  9. import java.util.Date;
  10. import java.util.List;
  11. @Entity
  12. @Table(name = "classification")
  13. @NoArgsConstructor
  14. public class Classification {
  15. @Getter
  16. @Setter
  17. @Id
  18. @GeneratedValue(strategy = GenerationType.IDENTITY)
  19. @Column(name = "e_id", nullable = false, columnDefinition = "BIGINT COMMENT '题目类别实体ID'")
  20. private Long e_id;
  21. @Getter
  22. @Setter
  23. @Column(name = "name", nullable = false, length = 32, columnDefinition = "VARCHAR(32) COMMENT '题目类别'")
  24. private String name;
  25. @Getter
  26. @Setter
  27. @Column(name = "introduction", columnDefinition = "VARCHAR(255) COMMENT '题目类别介绍'")
  28. private String introduction;
  29. @Getter
  30. @Setter
  31. @Column(name = "remark", columnDefinition = "VARCHAR(255) COMMENT '备注'")
  32. private String remark;
  33. @Getter
  34. @Setter
  35. @Column(name = "order_by", columnDefinition = "INT COMMENT '排序'")
  36. private Integer orderBy;
  37. @Getter
  38. @Setter
  39. @Column(name = "enabled", nullable = false, columnDefinition = "TINYINT DEFAULT 1 COMMENT '启用题库'")
  40. private Boolean enabled;
  41. @Getter
  42. @Setter
  43. @ManyToMany(cascade = CascadeType.REFRESH)
  44. @JoinTable(name = "classification_question",
  45. joinColumns = {@JoinColumn(name = "classification_id", referencedColumnName = "e_id", columnDefinition = "BIGINT COMMENT '题目类别实体ID'")},
  46. inverseJoinColumns = {@JoinColumn(name = "question_id", referencedColumnName = "e_id", columnDefinition = "BIGINT COMMENT '题目实体ID'")})
  47. // 题目(列表)
  48. private List<Question> questionList;
  49. @Getter
  50. @Setter
  51. @OneToMany(cascade = {CascadeType.REFRESH}, mappedBy = "classification", fetch = FetchType.LAZY)
  52. // 回复(集合)
  53. private List<Reply> replySet;
  54. @Getter
  55. @Setter
  56. @Column(name = "created_at", columnDefinition = "DATETIME COMMENT '创建时间'")
  57. @CreationTimestamp
  58. private Date createdAt;
  59. @Getter
  60. @Setter
  61. @Column(name = "updated_at", columnDefinition = "DATETIME COMMENT '更新时间'")
  62. @UpdateTimestamp
  63. private Date updatedAt;
  64. @Version
  65. @Column(name = "version", columnDefinition = "BIGINT COMMENT '版本号'")
  66. public Long version;
  67. }