package com.kiisoo.ic.system.enums;

import lombok.Getter;

/**
 * @author jinchaofan
 * @date 2020/2/26 14:19
 * @company kiisoo
 * @details 角色枚举
 */
@Getter
public enum  RoleEnum {

    ROLE_CODE_DZ("店长", "DZ-DIANZHANG"),

    ROLE_CODE_YYRY("运营人员", "DG-YUNYING"),

    ROLE_CODE_GLY("系统管理员", "GLY-ADMIN"),

    ROLE_CODE_DG("导购", "DG-DAOGOU"),

    ROLE_CODE_NULL("无此角色", "ROLE-NULL"),;

    /**
     * 角色名
     */
    private String roleName;

    /**
     * 角色码
     */
    private String roleCode;

    RoleEnum(String roleName, String roleCode) {
        this.roleName = roleName;
        this.roleCode = roleCode;
    }

    public static RoleEnum getCodeByName(String name){
        for (RoleEnum value : RoleEnum.values()) {
            if(value.getRoleName().equals(name)){
                return value;
            }
        }
        return ROLE_CODE_NULL;
    }

    public static RoleEnum getRoleByCode(String code){
        for (RoleEnum value : RoleEnum.values()) {
            if(value.getRoleCode().equals(code)){
                return value;
            }
        }
        return ROLE_CODE_NULL;
    }
}
