package com.cool.store.enums;

import org.apache.commons.lang3.StringUtils;

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

public enum SignTypeEnum {
    TRANSFER(0,"转让"),
    NEW_SIGNING(1,"新签"),
    RENEWAL(2,"续签"),
    RELOCATION (3,"迁址"),
    NEW_SIGNING_INDUSTRIES(5,"新签同异业转化"),
    OLD_NEW_OPEN(6,"老店新开"),
    DIRECT_SALES_TO_JOINING(7,"直营转加盟"),

    ;

    private Integer code;
    private String desc;



    SignTypeEnum(Integer code, String desc) {
        this.code = code;
        this.desc = desc;

    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

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

    public static SignTypeEnum getWorkflowStageByCode(Integer code) {
        if(code == null) {
            return null;
        }
        return map.get(code);
    }

    public static String getDescByCode(Integer code) {
        if(code == null) {
            return null;
        }
        SignTypeEnum signTypeEnum = map.get(code);
        if(signTypeEnum == null) {
            return null;
        }
        return signTypeEnum.getDesc();
    }
}
