package com.rf.psychological.dao.model;

import com.rf.psychological.base.model.BaseEntity;
import com.rf.psychological.security.EncryptDecodeConverter;
import lombok.*;
import org.hibernate.annotations.DynamicUpdate;

import javax.persistence.Column;
import javax.persistence.Convert;
import javax.persistence.Entity;
import javax.persistence.Table;

/**
 * @author zzf
 * @description:答案选项实体类
 * @date 2021/5/13 11:02
 */
@Entity
@Data
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "t_answer_info")
@org.hibernate.annotations.Table(appliesTo = "t_answer_info", comment = "答案选项表")
@DynamicUpdate
public class AnswerEntity extends BaseEntity {

    @Column(name = "question_no", columnDefinition = "varchar(10) comment '所属题号'")
    private String questionNo;

    @Convert(converter = EncryptDecodeConverter.class)
    @Column(name = "name", columnDefinition = "varchar(500) comment '答案内容'")
    private String name;

    @Column(name = "options", columnDefinition = "varchar(10) comment '选项值'")
    private String options;

    @Column(name = "question_type", columnDefinition = "varchar(10) comment '类型：0-单选 1-多选 2-填空'")
    private String questionType;

    @Convert(converter = EncryptDecodeConverter.class)
    @Column(name = "score", columnDefinition = "varchar(100) comment '分值'")
    private String score;

    @Column(name = "score_direction", columnDefinition = "varchar(10) comment '计分方向：1-正向；0-反向'")
    private String scoreDirection;

    @Column(name = "flag", columnDefinition = "varchar(50) comment '标识：所属量表'")
    private String flag;

    ///**
    // * 加密
    // */
    //public void encrypt() {
    //    this.score = DESede.encryptString(this.score);
    //    this.name = DESede.encryptString(this.name);
    //}
    //
    ///**
    // * 进行解密
    // */
    //public void decrypt() {
    //    this.score = DESede.decryptString(this.score);
    //    this.name = DESede.decryptString(this.name);
    //}

}
