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_marks")
@org.hibernate.annotations.Table(appliesTo = "t_scale_marks", comment = "评分规则表")
@DynamicUpdate
public class ScaleMarksEntity extends BaseEntity {

    @Column(name = "name", columnDefinition = "varchar(400) comment '维度名称'")
    @Convert(converter = EncryptDecodeConverter.class)
    private String name;

    @Column(name = "score_start", columnDefinition = "varchar(100) comment '起始分'")
    @Convert(converter = EncryptDecodeConverter.class)
    private String scoreStart;

    @Column(name = "score_end", columnDefinition = "varchar(100) comment '结束分'")
    @Convert(converter = EncryptDecodeConverter.class)
    private String scoreEnd;

    @Column(name = "symptom", columnDefinition = "text comment '该分段症状(结论)'")
    @Convert(converter = EncryptDecodeConverter.class)
    private String symptom;

    @Column(name = "improvement_suggestions", columnDefinition = "text comment '该分段指导语（等级解释）（维度说明）'")
    @Convert(converter = EncryptDecodeConverter.class)
    private String improvementSuggestions;

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

    @Column(name = "reference", columnDefinition = "varchar(300) default '无' comment '常模参考值'")
    @Convert(converter = EncryptDecodeConverter.class)
    private String reference;

    @Column(name = "standard_deviation", columnDefinition = "varchar(300) default '无' comment '标准差'")
    @Convert(converter = EncryptDecodeConverter.class)
    private String standardDeviation;

    @Column(name = "name_explain", columnDefinition = "text comment '因子解释(维度解读)'")
    @Convert(converter = EncryptDecodeConverter.class)
    private String nameExplain;

    @Column(name = "suggestion", columnDefinition = "text comment '建议'")
    @Convert(converter = EncryptDecodeConverter.class)
    private String suggestion;

    @Column(name = "is_total_score_explain", columnDefinition = "varchar(50) default '否' comment '是否为总分结论'")
    private String isTotalScoreExplain;

    @Column(name = "scoring_type", columnDefinition = "varchar(2) default '0' comment '计分类型：0---求和，1---求平均值保留两位小数，2---求平均值四舍五入'")
    private String scoringType;



    ///**
    // * 加密
    // */
    //public void encrypt() {
    //    this.name = DESede.encryptString(this.name);
    //    this.scoreStart = DESede.encryptString(this.scoreStart);
    //    this.scoreEnd = DESede.encryptString(this.scoreEnd);
    //    this.symptom = DESede.encryptString(this.symptom);
    //    this.improvementSuggestions = DESede.encryptString(this.improvementSuggestions);
    //}
    //
    ///**
    // * 解密代码
    // */
    //public void decrypt() {
    //    this.name = DESede.decryptString(this.name);
    //    this.scoreStart = DESede.decryptString(this.scoreStart);
    //    this.scoreEnd = DESede.decryptString(this.scoreEnd);
    //    this.symptom = DESede.decryptString(this.symptom);
    //    this.improvementSuggestions = DESede.decryptString(this.improvementSuggestions);
    //}
}
