package com.mortals.xhx.common.code;

import com.mortals.framework.ap.SysConstains;
import com.mortals.framework.common.IBaseEnum;

import java.util.LinkedHashMap;
import java.util.Map;

public enum MenuAuthType implements IBaseEnum{
	 /** 无限制 */
    UNLIMIT(0, "无限制", SysConstains.STYLE_DEFAULT),
    /** 无需登录查看 */
    WITHOUTLOGIN(1, "无需登录查看", SysConstains.STYLE_DEFAULT),
    /** 需要登录查看 */
    WITHLOGIN(2, "需要登录查看", SysConstains.STYLE_DEFAULT),
    /** 需要角色权限查看 */
    WITHAUTHORITY(3, "需要角色权限查看", SysConstains.STYLE_DEFAULT);
    
    private int value;
    private String desc;
    private String style;

    MenuAuthType(int value, String desc, String style) {
        this.value = value;
        this.desc = desc;
        this.style = style;
    }

    @Override
    public int getValue() {
        return this.value;
    }

    public String getDesc() {
        return desc;
    }

    public String getStyle()
	{
		return style;
	}

	public static MenuAuthType getByValue(int value) {
        for (MenuAuthType menuAuthType : MenuAuthType.values()) {
            if (menuAuthType.getValue() == value) {
                return menuAuthType;
            }
        }
        return null;
    }
	/**
	 * 获取Map集合
	 * @param eItem 不包含项
	 * @return
	 */
	public static Map<String,String> getEnumMap(int... eItem) {
		Map<String,String> resultMap= new LinkedHashMap<String,String>();
		for (MenuAuthType item : MenuAuthType.values()) {
			try{
				boolean hasE = false;
				for (int e : eItem){
					if(item.getValue()==e){
						hasE = true;
						break;
					}
				}
				if(!hasE){
					resultMap.put(item.getValue()+"", item.getDesc());
				}
			}catch(Exception ex){
			}
		}
		return resultMap;
	}
}
