package com.engine.salary.enums.salarysob;


import com.engine.salary.enums.BaseEnum;
import com.google.common.collect.Maps;

import java.util.*;
import java.util.stream.Collectors;

/**
 * 人员范围的对象类型
 * <p>Copyright: Copyright (c) 2022</p>
 * <p>Company: 泛微软件</p>
 *
 * @author qiantao
 * @version 1.0
 **/
public enum TargetTypeEnum implements BaseEnum<Integer> {
    EMPLOYEE(1, "人员", 100133),
    DEPT(2, "部门", 86185),
    SUBCOMPANY(3, "分部", 107369),
    POSITION(4, "岗位", 90633),
    ALL(5, "所有人", 107729);

//    SECLEVE(6, "安全级别", 90382),;
    //    EXT_EMPLOYEE(100, "外部人员", 0);
    private int value;

    private String defaultLabel;

    private int labelId;

    TargetTypeEnum(int value, String defaultLabel, int labelId) {
        this.value = value;
        this.defaultLabel = defaultLabel;
        this.labelId = labelId;
    }


    @Override
    public Integer getValue() {
        return value;
    }

    @Override
    public Integer getLabelId() {
        return labelId;
    }

    @Override
    public String getDefaultLabel() {
        return defaultLabel;
    }

    /**
     * 获取下拉列表
     *
     * @return
     */
    public static List<Map<String, Object>> getSelectList() {
        return Arrays.asList(TargetTypeEnum.values()).stream().filter(e -> e != ALL ).map(e -> {
            Map<String, Object> map = Maps.newHashMap();
            map.put("id", e.name());
            map.put("name", e.defaultLabel);
            map.put("value", e.value);
            return map;
        }).collect(Collectors.toList());
    }

    public static TargetTypeEnum parseByValue(Integer value) {
        for (TargetTypeEnum targetTypeEnum : TargetTypeEnum.values()) {
            if (Objects.equals(targetTypeEnum.getValue(), value)) {
                return targetTypeEnum;
            }
        }
        return null;
    }
}
