You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
spring-boot-online-exam/backend/src/main/java/lsgwr/exam/entity/Exam.java

113 lines
3.6 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

/***********************************************************
* @Description : 考试表,要有题目、总分数、时间限制、有效日期、创建者等字段
* @author : 梁山广(Laing Shan Guang)
* @date : 2019/5/14 07:42
* @email : liangshanguang2@gmail.com
***********************************************************/
// 定义包名,用于组织类文件,避免命名冲突
package lsgwr.exam.entity;
// 导入Jackson库的JsonFormat注解用于JSON序列化时自定义日期格式
import com.fasterxml.jackson.annotation.JsonFormat;
// 导入Lombok库的Data注解用于自动生成getter、setter、equals、hashCode和toString方法
import lombok.Data;
// 导入Hibernate的DynamicUpdate注解用于在实体更新时只更新发生变化的字段
import org.hibernate.annotations.DynamicUpdate;
// 导入JPA的Entity注解用于声明该类是一个JPA实体类
import javax.persistence.Entity;
// 导入JPA的Id注解用于声明该类中的某个字段作为主键
import javax.persistence.Id;
// 导入Java的Date类用于表示日期和时间
import java.util.Date;
@Entity
@Data
@DynamicUpdate
/**
* 考试实体类
*/
public class Exam {
// 使用JPA的@Id注解声明该字段为主键
/**
* 考试ID唯一标识一场考试
*/
@Id
private String examId;
/**
* 考试名称
*/
private String examName;
/**
* 考试头像或图标
*/
private String examAvatar;
/**
* 考试描述或简介
*/
private String examDescription;
/**
* 存储所有问题ID的字符串可能是逗号分隔的ID列表
*/
private String examQuestionIds;
/**
* 存储所有单选题ID的字符串
*/
private String examQuestionIdsRadio;
/**
* 存储所有多选题ID的字符串
*/
private String examQuestionIdsCheck;
/**
* 存储所有判断题ID的字符串
*/
private String examQuestionIdsJudge;
/**
* 考试总分
*/
private Integer examScore;
/**
* 单选题总分
*/
private Integer examScoreRadio;
/**
* 多选题总分
*/
private Integer examScoreCheck;
/**
* 判断题总分
*/
private Integer examScoreJudge;
/**
* 创建者ID标识谁创建了这场考试
*/
private String examCreatorId;
/**
* 考试时间限制,单位可能是分钟
*/
private Integer examTimeLimit;
/**
* 考试开始时间使用Jackson的@JsonFormat注解自定义日期格式
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date examStartDate;
/**
* 考试结束时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date examEndDate;
/**
* 创建时间设计数据库表时设置了自动插入当前时间因此在Java代码中无需手动设置。
* 使用Jackson的@JsonFormat注解自定义日期格式以便于前端展示。
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date createTime;
/**
* 更新时间设计数据库表时也设置了自动插入当前时间或更新为当前时间在Java代码中无需手动维护。
* 同时由于使用了Hibernate的@DynamicUpdate注解当数据库中的实体数据发生变化时该字段会自动更新为当前时间。
* 使用Jackson的@JsonFormat注解自定义日期格式以便于前端展示。
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date updateTime;
}