package com.qmth.themis.business.enums;

import java.util.Objects;

/**
 * @Description: 唯一约束字段转换
 * @Param:
 * @return:
 * @Author: wangliang
 * @Date: 2020/7/13
 */
public enum FieldUniqueEnum {

    t_e_exam_orgId_code_Idx("考试批次编码"),

    t_e_exam_activity_examId_code_Idx("考场批次编码"),

    t_e_exam_course_examId_courseCode_Idx("考试科目编码"),

    t_e_exam_paper_examId_code_Idx("考试试卷编码"),

    t_e_exam_student_examId_roomCode_Idx("考场代码"),

    t_e_student_orgId_identity_Idx("证件号"),

    t_b_exam_invigilate_user_orgId_userId_roomCode_Idx("监考员"),

    t_b_user_loginName_orgId_Idx("登录名"),

    t_ie_exam_invigilate_call_recordId_source_Idx("监考视频源"),
    
    t_e_exam_short_code_Idx("考试口令"),

    t_b_org_code_Idx("机构代码"),

    org_login_name("登录名"),

    union_identity_index("考生证件号"),

    room_code_index("该考试批次下考场编码"),

    activity_idx("语音消息"),

    soft_index("软件和进程名称"),

    t_ie_exam_media_log_UN_content("多媒体消息"),

    t_e_exam_summary_UN("考试统计"),

    t_e_region_summary_UN("地区统计");

    private String code;

    private FieldUniqueEnum(String code) {
        this.code = code;
    }

    public String getCode() {
        return code;
    }

    /**
     * 状态转换 toName
     *
     * @param value
     * @return
     */
    public static String convertToName(String value) {
        for (FieldUniqueEnum e : FieldUniqueEnum.values()) {
            if (Objects.equals(value.trim(), e.code)) {
                return e.name();
            }
        }
        return null;
    }

    /**
     * 状态转换 toCode
     *
     * @param value
     * @return
     */
    public static String convertToCode(String value) {
        for (FieldUniqueEnum e : FieldUniqueEnum.values()) {
            if (value.trim().contains(e.name())) {
                return e.code;
            }
        }
        return null;
    }
}
