package com.crunii.micro.service.sysmgr.api.enums;

import org.apache.commons.lang3.StringUtils;

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

public enum PushTerminalEnum {

    PC((byte)1, "PC"),
    APP((byte)2, "APP"),
    CONTROL_WEB((byte)3, "管理台"),
    PUBLIC_ACCOUNT((byte)4, "公众号");

    Byte type;

    String typeName;

    PushTerminalEnum(Byte type, String typeName){
        this.type = type;
        this.typeName = typeName;
    }

    public Byte getType() {
        return type;
    }

    public String getTypeName() {
        return typeName;
    }

    public static String convert(String raw){
        if (StringUtils.isBlank(raw)){
            return null;
        }
        Map<Byte, String> map = Arrays.stream(PushTerminalEnum.values()).collect(Collectors.toMap(PushTerminalEnum::getType, PushTerminalEnum::getTypeName));
        return Arrays.stream(raw.split(",")).map(item -> map.get(Byte.valueOf(item))).collect(Collectors.joining("、"));
    }
}
