package com.pangu.member.enums;

/**
 * 身份类型枚举
 * @author pangu
 */
public enum IdentityTypeEnum {

    PARENT("1", "家长"),
    TEACHER("2", "教师");

    private final String code;
    private final String name;

    IdentityTypeEnum(String code, String name) {
        this.code = code;
        this.name = name;
    }

    public String getCode() {
        return code;
    }

    public String getName() {
        return name;
    }

    /**
     * 根据代码获取名称
     */
    public static String getNameByCode(String code) {
        for (IdentityTypeEnum type : values()) {
            if (type.getCode().equals(code)) {
                return type.getName();
            }
        }
        return "";
    }

    /**
     * 是否为教师
     */
    public static boolean isTeacher(String code) {
        return TEACHER.getCode().equals(code);
    }

    /**
     * 是否为家长
     */
    public static boolean isParent(String code) {
        return PARENT.getCode().equals(code);
    }
}
