package com.ywt.mg.domain.models.enums;

public enum UserTypeEnum {
    General("普通用户", 1),
    Doctor("医生", 2),
    Merchant("经销商", 4),
    Agent("代表", 8),
    REPS("医药代表", 16),
    Pharmacist("发药师", 32);

    public final String displayName;

    public final int value;

    UserTypeEnum(String displayName, int value) {
        this.displayName = displayName;
        this.value = value;
    }

    public String getDisplayName() {
        return displayName;
    }

    public int getValue() {
        return value;
    }

    public static UserTypeEnum valueOf(int value) {
        if ((value & Pharmacist.value) == Pharmacist.value) {
            return Pharmacist;
        } else if ((value & REPS.value) == REPS.value) {
            return REPS;
        } else if ((value & Agent.value) == Agent.value) {
            return Agent;
        } else if ((value & Merchant.value) == Merchant.value) {
            return Merchant;
        } else if ((value & Doctor.value) == Doctor.value) {
            return Doctor;
        }
        return General;
    }

}
