package com.qmth.paper.library.common.enums;

import java.util.Objects;

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

    user_schoolId_loginName_idx("登录名"),

    org_schoolId_code_idx("机构编码"),

    org_schoolId_name_idx("机构名称"),

    role_schoolId_name_idx("角色名"),

    uq_school_id_mobile_number("手机号码"),

    clazz_schoolId_name_idx("班级名称"),

    semester_schoolId_name_idx("学期名称"),

    student_schoolId_code_orgId_idx("学生学号"),

    role_group_roleId_memberId_idx("角色成员数据重复，同角色其它用户已绑定");

    private String title;

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

    public String getTitle() {
        return title;
    }

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

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