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

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

    private final String displayName;

    private 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 & Agent.getValue()) == Agent.getValue()) {
            return Agent;
        }
        else if ((value & Merchant.getValue()) == Merchant.getValue()) {
            return Merchant;
        }
        else if ((value & Doctor.getValue()) == Doctor.getValue()) {
            return Doctor;
        }
        else if ((value & General.getValue()) == General.getValue()) {
            return General;
        }
        else{
            return General;
        }
    }
}
