package com.tofly.dispatch.em;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

import java.util.HashMap;
import java.util.Map;

/**
 * 流程类型字典
 */
@Getter
@AllArgsConstructor //全参构造函数
@NoArgsConstructor  //无参构造函数
public enum ProcessTypeEnum {
    ONE("会议室","TF_YWPN_CONFERENCE_ROOM_W",1,1),
    TWO("资产管理","TF_YWPN_ASSETS_W",2,1),
    THREE("文档、公告、文件","TF_YWPN_DOCUMENT_W",3,1);

    private String value;

    private String table;

    private Integer key;

    private Integer type;

    public static String loadValue(int key){
        for (ProcessTypeEnum e:ProcessTypeEnum.values()) {
            if(e.key==key){
                return e.getValue();
            }
        }
        return null;
    }

    public static String loadTable(int key){
        for (ProcessTypeEnum e:ProcessTypeEnum.values()) {
            if(e.key==key){
                return e.getTable();
            }
        }
        return null;
    }

    public static Map<Integer,String> getMap(Integer type){
        Map<Integer,String> map = new HashMap<>();
        for (ProcessTypeEnum e:ProcessTypeEnum.values()) {
            if(type==null||type==e.type) {
                map.put(e.key, e.value);
            }
        }
        return map;
    }


}
