package com.cirle.scientific.questionnaire.entity;

import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.Where;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import java.time.LocalDateTime;

/**
 * 问卷答案实体类
 */
@Getter
@Setter
@Entity
@Table(name = "questionnaire_question_answer")
@SQLDelete(sql = "UPDATE questionnaire_question_answer SET deleted = true WHERE id=?")
@Where(clause = "deleted=false")
public class AnswerEntity {

    // ID：实体的唯一标识，不建议用于业务用途
    @Id
    @GeneratedValue(generator = "UUID")
    @GenericGenerator(name = "UUID", strategy = "org.hibernate.id.UUIDGenerator")
    @NotNull
    private String id;

    // 回答者ID（即答卷人）
    @NotNull
    private String userId;

    // 问卷ID
    @NotNull
    private String questionnaireId;

    // 问题ID
    @NotNull
    private String questionId;

    // 选项ID（仅当问题类型为判断题、单选题、多选题时该字段才有意义）
    private String optionId;

    // 答案文本（仅当问题类型为问答题时该字段才有意义）
    private String text;

    // 创建时间
    @NotNull
    private LocalDateTime createTime;

    // 上次修改时间
    private LocalDateTime lastModifiedTime;

    // 逻辑删除标识（默认值为False）
    @NotNull
    private Boolean deleted = Boolean.FALSE;

}
