package com.cool.store.enums;

import org.apache.commons.lang3.StringUtils;

import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;

/**
 * @Author suzhuhong
 * @Date 2023/6/9 16:17
 * @Version 1.0
 */
public enum WorkflowStageEnum {

    INTENT("1","意向申请阶段"),
    RESERVATION("2","预约面试阶段"),
    INTERVIEW("3","合格资格面试"),
    ;

    private String code;

    private String message;

    WorkflowStageEnum(String code, String message) {
        this.code = code;
        this.message = message;
    }

    /**
     * 每个大节点对应的子节点最后一个流程
     * @return
     */
    public static final HashMap<String,String> getWorkflowStageMap(){
        HashMap<String, String> result = new HashMap<>();
        result.put(INTENT.getCode(),WorkflowStatusEnum.INTENT_3.getCode());
        result.put(RESERVATION.getCode(),WorkflowStatusEnum.RESERVATION_7.getCode());
        result.put(INTERVIEW.getCode(),WorkflowStatusEnum.INTERVIEW_7.getCode());
        return result;
    }


    public String getCode() {
        return code;
    }

    public String getMessage() {
        return message;
    }

    protected static final Map<String, WorkflowStageEnum> map = Arrays.stream(values()).collect(
            Collectors.toMap(WorkflowStageEnum::getCode, Function.identity()));

    public static WorkflowStageEnum getWorkflowStageByCode(String code) {
        if(StringUtils.isBlank(code)) {
            return null;
        }
        return map.get(code);
    }
}
