package com.rf.psychological.scale.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
@EqualsAndHashCode(callSuper=true)
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "t_scale_info")
@org.hibernate.annotations.Table(appliesTo = "t_scale_info", comment = "通用量表")
@DynamicUpdate
public class ScaleEntity extends BaseEntity {

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

    @Column(name = "serial_no", columnDefinition = "varchar(10) comment '序号，展示顺序'")
    private String serialNo;

    @Column(name = "content", columnDefinition = "varchar(3000) comment '题目内容'")
    @Convert(converter = EncryptDecodeConverter.class)
    private String answer;

    @Column(name = "check_item", columnDefinition = "varchar(3000) comment '选项'")
    @Convert(converter = EncryptDecodeConverter.class)
    private String checkItems;

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

    @Column(name = "question_param", columnDefinition = "text comment '题目类型对应参数'")
    private String questionParam;

    @Column(name = "weight", columnDefinition = "varchar(10) comment '分量'")
    private String weight;

    @Column(name = "score", columnDefinition = "varchar(10) 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.answer = DESede.encryptString(this.answer);
    //    this.checkItems = DESede.encryptString(this.checkItems);
    //}
    //
    ///**
    // * 解密代码
    // */
    //public void decrypt() {
    //    this.answer = DESede.decryptString(this.answer);
    //    this.checkItems = DESede.decryptString(this.checkItems);
    //}

}
